')
.addClass('autoGrowHiddenDiv')
.html(hiddenHtmlContent)
.css({
'font-size': targetTextarea.css('font-size'),
'line-height': targetTextarea.css('line-height'),
'font-family': targetTextarea.css('font-family')
});
//DZ 30apr17: putting hiddenDiv in container, with larger width, due to autosize issue when width exceeds page width (it forces line breaking), see ME-22, ME-26
//$('body').append(hiddenDiv);
$('#autoGrowDivHolder').append(hiddenDiv);
var newWidth = hiddenDiv.width();
//debug.log('================ currentValue', currentValue, newWidth);
//adding some more width, so entering new chars wont cause it to blink, compensating in margin-left
var sideMarginWidth = (parseFloat(targetTextarea.css('font-size').replace('px', '')));
if (targetTextarea.css('text-align') == 'left')
{
newWidth = newWidth + sideMarginWidth;
}
else if (targetTextarea.css('text-align') == 'right')
{
newWidth = newWidth + sideMarginWidth;
targetSlot.css('margin-left', -sideMarginWidth + 'px');
}
else if (targetTextarea.css('text-align') == 'center')
{
newWidth = newWidth + sideMarginWidth;
targetSlot.css('margin-left', -(sideMarginWidth/2) + 'px');
}
//debug.log('================ currentValueAfterMargin', currentValue, newWidth);
var minHeight = parseFloat(targetTextarea.css('line-height').replace('px', ''));
var newHeight = hiddenDiv.height();
if (newHeight < minHeight) newHeight = minHeight;
//only for events (not init time) - expanding size according to alignment
var fix_left_by_text_alignment = e.target || forceAlignmentFix;
if (fix_left_by_text_alignment && (targetTextarea.css('text-align') == 'right' || targetTextarea.css('text-align') == 'center')) {
var widthDiff = newWidth - prevWidth;
var prevLeft = parseFloat(targetSlot.css('left').replace('px', ''));
var newLeft = (targetTextarea.css('text-align') == 'right') ? prevLeft - widthDiff : prevLeft - (widthDiff / 2);
//debug.log(newLeft, prevLeft);
targetSlot.css('left', newLeft + 'px');
}
targetTextarea.css({
width: newWidth + 'px',
height: newHeight + 'px'
});
hiddenDiv.remove();
var thisDraggable = $(this);
//DZ 22may17: putting inside short short timeout, because of ME-55 bug in mobile (happens also on drag/move - sticky handle doesnt fit right place)
setTimeout(function () {
desLogic.reposition_sticky_handles(targetSlot);
}, 25);
}
//-----------------------------------------------
//DZ CODE: get edge of jqElm
function getEdgeX(jqElm) {
return parseFloat(jqElm.css('left').replace('px', '')) + jqElm.width();
}
function getEdgeY(jqElm) {
return parseFloat(jqElm.css('top').replace('px', '')) + jqElm.height();
}
//DZ CODE: get resized_image
function resize_img(img_src, targetWidth, succFunc)
{
async_create_and_load_image(img_src, function (imgObj) {
var targetHeight = targetWidth * imgObj.height / imgObj.width;
debug.log('compressing image from ' + imgObj.width + 'x' + imgObj.height + 'to ' + targetWidth + 'x' + targetHeight);
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = targetWidth;
canvas.height = targetHeight;
//DZ 5aug14: fixing an issue that occured in iPad Safari, only for a specific photo.jpeg (3264x2448), only after compressed.)
//see http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios
//DZ 7dec14: using param from new_editor.js
//var isIpad = categorizr() == 'tablet';
var isIpad = browser_category == 'tablet';
if (!isIpad)
/// draw source image into the off-screen canvas:
ctx.drawImage(imgObj, 0, 0, targetWidth, targetHeight);
else
{
debug.log('using ipad fix for compression');
//drawImageIOSFix(ctx, imgObj, 0, 0, targetWidth, targetHeight, 0, 0, targetWidth, targetHeight);
var nw = imgObj.naturalWidth, nh = imgObj.naturalHeight;
// MegaPixImage constructor accepts File/Blob object.
var mpImg = new MegaPixImage(imgObj);
mpImg.render(canvas, { width: targetWidth, height: targetHeight });
}
var resizedImageSrc = canvas.toDataURL();
async_create_and_load_image(resizedImageSrc, function (resizedImgObj) {
debug.log('new compressed imaged dims: ', resizedImgObj.width, resizedImgObj.height);
succFunc(resizedImgObj);
});
});
}
//get QUERYSTRING param:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//PRELOAD IMAGES:
function preload(arrayOfImages) {
$(arrayOfImages).each(function () {
$('
![]()
')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
//TURBO VERSION
//returns a rotated img, cloned with canvas
function get_rotated_image_helper(imgSrc, degree, succFunc) {
if (degree == 0)
succFunc(imgSrc);
else {
//console.log('---loading', imgSrc.length);
//DZ 21jun15: trying to avoid CORS issue by different loading of image
async_create_and_load_image(imgSrc, function (img) {
debug.log('---loaded for rotation');
//var img = this;
var canvas = document.createElement('canvas');
var cContext = canvas.getContext('2d');
var cw = img.width, ch = img.height, cx = 0, cy = 0;
// Calculate new canvas size and x/y coorditates for image
switch (degree) {
case 90:
cw = img.height;
ch = img.width;
cy = img.height * (-1);
break;
case 180:
cx = img.width * (-1);
cy = img.height * (-1);
break;
case 270:
cw = img.height;
ch = img.width;
cx = img.width * (-1);
break;
}
// Rotate image
canvas.setAttribute('width', cw);
canvas.setAttribute('height', ch);
cContext.rotate(degree * Math.PI / 180);
cContext.drawImage(img, cx, cy);
debug.log('---rotated image drawn');
var newImgData = canvas.toDataURL("image/jpeg");
debug.log('---rotated base64 image created');
succFunc(newImgData);
});
}
}
//native js replace replaces only first occurance
function strreplace(str, search, replacement) {
if (str == null)
return null;
else
return str.split(search).join(replacement);
}
function fixGIText(text) {
return strreplace(text, '~', '\n');
//return strreplace(strreplace(text, '~~', '\n'), '~', '\n');
}
function get_font_name_span_id(fontName) {
return $.trim('span_font_sel_' + strreplace(strreplace(strreplace($.trim(fontName), "'", ""), '"', ''), ' ', '_')).toLowerCase();
}
function lineHeightMultiplier(fontSize, fontName) {
//DZ: 22oct14: TESTING, DEBUGGING, after adding this as a required parameter
if (fontName == null)
{
alert('fontname not provided!');
}
var multiplier = 1.2; //was 1.2
var elmWithMultiplier = $('#' + get_font_name_span_id(fontName));
if (elmWithMultiplier.length == 0 || !elmWithMultiplier[0].hasAttribute('line_height_multiplier')) {
//DZ 3jan17: removed warning - not really unexpected behavior
//console.error('No line_height_multiplier found for font ' + fontName, "'" + get_font_name_span_id(fontName) + "'");
//alert('GI: plz tell me if you see this alert, and when/why');
}
else
multiplier = parseFloat(elmWithMultiplier.attr('line_height_multiplier'));
var ret = fontSize * multiplier;
//console.log('lineHeightMultiplier', fontName, fontSize, multiplier, ret);
return ret;
//return fontSize * 1.43;
}
function getRendererFontLocationFixDiff(fontSize, fontName) {
//DZ: 22oct14: TESTING, DEBUGGING, after adding this as a required parameter
if (fontName == null) {
alert('fontname not provided!');
}
const isChromeBrowser = isChrome();
const browserVersion = getBrowser().version;
let firefoxMultipler = 0;
let chromeMultipler = 0;
let osxMultiplier = 0;
let renderTimeMultipler = 0;
let ret = 0;
var elmWithMultiplier = $('#' + get_font_name_span_id(fontName));
if (elmWithMultiplier.length == 0){
//shouldnt really happen:
debug.error('No font span found for font ' + fontName, "'" + get_font_name_span_id(fontName) + "'");
//alert('GI: plz tell me if you see this alert, and when/why');
}
else {
// 1. Fixes for all Browsers
if (elmWithMultiplier[0].hasAttribute('all_y_fix'))
renderTimeMultipler = parseFloat(elmWithMultiplier.attr('all_y_fix'));
if ($('#font_debug_section_fix').length > 0 && $('#font_debug_section_fix').val() != '') {
console.log('Applying font fix for all browsers');
renderTimeMultipler = parseFloat($('#font_debug_section_fix').val());
}
// 2. Additional fixes to other browsers (Firefox, Chrome)
const userAgentInfo = sayswho().toLowerCase();
switch (true) {
case userAgentInfo.indexOf("firefox") >= 0:
if (elmWithMultiplier[0].hasAttribute('ff_y_fix')) {
firefoxMultipler = parseFloat(elmWithMultiplier.attr('ff_y_fix'));
}
if ($('#font_debug_section_fix_ff').length > 0 && $('#font_debug_section_fix_ff').val() != '') {
console.log('Applying font fix for FireFox');
firefoxMultipler = parseFloat($('#font_debug_section_fix_ff').val());
}
break;
case isChromeBrowser === true && browserVersion >= 71:
if (elmWithMultiplier[0].hasAttribute('chrome_y_fix')) {
chromeMultipler = parseFloat(elmWithMultiplier.attr('chrome_y_fix'));
}
if ($('#font_debug_section_fix_chrome').length > 0 && $('#font_debug_section_fix_chrome').val() != '') {
console.log('Applying font fix for Chrome');
chromeMultipler = parseFloat($('#font_debug_section_fix_chrome').val());
}
break;
}
// 3. Additional fixes to OSX
if (getOSName() == "MacOS" && !isChromeBrowser) {
if (elmWithMultiplier[0].hasAttribute('osx_y_fix'))
osxMultiplier = parseFloat(elmWithMultiplier.attr('osx_y_fix'));
if ($('#font_debug_section_fix_osx').length > 0 && $('#font_debug_section_fix_osx').val() != '') {
console.log('Applying font fix for OSX');
osxMultiplier = parseFloat($('#font_debug_section_fix_osx').val());
}
}
ret = (renderTimeMultipler + firefoxMultipler + osxMultiplier + chromeMultipler) * fontSize;
}
return ret;
}
function getFontName(oldFontName) {
//console.log("OLDFONT: " + oldFontName);
//DZ 15feb16: not returning without quotes
if (oldFontName.toLowerCase().indexOf('weird') > 0)
//return "Mountains of Christmas";
oldFontName = "Mountains of Christmas";
if (oldFontName.toLowerCase().indexOf('comic') >= 0)
//return "Patrick Hand";
oldFontName = "Patrick Hand";
//DZ 10feb16 fix: removing quotes from fontnames if not required:
var ret = strreplace(strreplace(oldFontName, "'", ""), '"', "");
if (ret.indexOf(' ') > 0)
ret = "'" + ret + "'";
//console.log("NEWFONT: " + ret);
return ret;
}
function split_text_contents_to_line_seperated_spans(jqElm) {
var retLines = [];
//retLines[0] = '';
var originalText = jqElm.val();
var last_height = 0;
jqElm.val('')
var sep_lines = originalText.split('\n');
for (l = 0 ; l < sep_lines.length ; l++) {
retLines[retLines.length] = '';
var this_line = sep_lines[l];
var sep_chars = this_line.split('');
for (c = 0 ; c < sep_chars.length ; c++) {
var curr_char = sep_chars[c];
jqElm.val(jqElm.val() + curr_char);
jqElm.trigger('autosize.resize');
var new_line_in_textarea = last_height < jqElm.innerHeight();
//console.log(curr_char, jqElm.innerHeight(), new_line_in_textarea ? '_NEWLINE_' : '_________', retLines[retLines.length - 1]);
//if not new line, or first char in new line
if (!new_line_in_textarea || retLines[retLines.length - 1] == '')
//no unaccounted line added in textarea for this char
retLines[retLines.length - 1] += curr_char;
else {
//new line caused by this char
if (c == 0)
//first char in line - new line already counted for
retLines[retLines.length] = c;
else {
var spaceIdx = retLines[retLines.length - 1].lastIndexOf(' ');
//new line in middle of a middle word:
if (spaceIdx > 0) {
var word_until_here = retLines[retLines.length - 1].substring(spaceIdx + 1);
//remove word from previous line:
retLines[retLines.length - 1] = retLines[retLines.length - 1].substring(0, spaceIdx);
//place word+char in new line:
retLines[retLines.length] = word_until_here + curr_char;
}
else {
//new line in middle of a first (or only) word in line
//just skip the char to the next line
retLines[retLines.length] = curr_char;
}
}
}
last_height = jqElm.innerHeight();
}
if (l != sep_lines.length - 1)
jqElm.val(jqElm.val() + '\n');
}
return retLines;
}
//used in text 2 canvas color (css returns as "rgb(229, 61, 57)"), and IE returns something else
function rgb2hex(rgb) {
if (rgb.search("rgb") == -1) {
return rgb;
} else {
rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
}
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
* ======= DZ: USED IN GREETINS_ISLAND TO ENABLE IPAD drag/drop control (for stickers and sliders) =======
*/
try
{
!function (a) { function f(a, b) { if (!(a.originalEvent.touches.length > 1)) { a.preventDefault(); var c = a.originalEvent.changedTouches[0], d = document.createEvent("MouseEvents"); d.initMouseEvent(b, !0, !0, window, 1, c.screenX, c.screenY, c.clientX, c.clientY, !1, !1, !1, !1, 0, null), a.target.dispatchEvent(d) } } if (a.support.touch = "ontouchend" in document, a.support.touch) { var e, b = a.ui.mouse.prototype, c = b._mouseInit, d = b._mouseDestroy; b._touchStart = function (a) { var b = this; !e && b._mouseCapture(a.originalEvent.changedTouches[0]) && (e = !0, b._touchMoved = !1, f(a, "mouseover"), f(a, "mousemove"), f(a, "mousedown")) }, b._touchMove = function (a) { e && (this._touchMoved = !0, f(a, "mousemove")) }, b._touchEnd = function (a) { e && (f(a, "mouseup"), f(a, "mouseout"), this._touchMoved || f(a, "click"), e = !1) }, b._mouseInit = function () { var b = this; b.element.bind({ touchstart: a.proxy(b, "_touchStart"), touchmove: a.proxy(b, "_touchMove"), touchend: a.proxy(b, "_touchEnd") }), c.call(b) }, b._mouseDestroy = function () { var b = this; b.element.unbind({ touchstart: a.proxy(b, "_touchStart"), touchmove: a.proxy(b, "_touchMove"), touchend: a.proxy(b, "_touchEnd") }), d.call(b) } } }(jQuery);
}
catch (e)
{
//DZ 7may17: adding catch, because sometimes fails on Yair's laptop.
//TODO: try to figure out wtf
console.warn('failed on jq touch punch', e);
}
/* DZ 28mar17: upgrading to 3.2.2 from 2.0.5 */
//================================================================================================================================================
/**
* @license jquery.panzoom.js v2.0.5
* Updated: Thu Apr 24 2014
* Add pan and zoom functionality to any element
* Copyright (c) 2014 timmy willison
* Released under the MIT license
* https://github.com/timmywil/jquery.panzoom/blob/master/MIT-License.txt
* ======= DZ: USED IN GREETINGS_ISLAND TO ENABLE PAN/ZOOMING OF IMAGES =======
*/
!function (a, b) { "function" == typeof define && define.amd ? define(["jquery"], function (c) { return b(a, c) }) : "object" == typeof exports ? b(a, require("jquery")) : b(a, a.jQuery) }("undefined" != typeof window ? window : this, function (a, b) { "use strict"; function c(a, b) { for (var c = a.length; --c;) if (+a[c] !== +b[c]) return !1; return !0 } function d(a) { var c = { range: !0, animate: !0 }; return "boolean" == typeof a ? c.animate = a : b.extend(c, a), c } function e(a, c, d, e, f, g, h, i, j) { this.elements = "array" === b.type(a) ? [+a[0], +a[2], +a[4], +a[1], +a[3], +a[5], 0, 0, 1] : [a, c, d, e, f, g, h || 0, i || 0, j || 1] } function f(a, b, c) { this.elements = [a, b, c] } function g(a, c) { if (!(this instanceof g)) return new g(a, c); 1 !== a.nodeType && b.error("Panzoom called on non-Element node"), b.contains(l, a) || b.error("Panzoom element must be attached to the document"); var d = b.data(a, m); if (d) return d; this.options = c = b.extend({}, g.defaults, c), this.elem = a; var e = this.$elem = b(a); this.$set = c.$set && c.$set.length ? c.$set : e, this.$doc = b(a.ownerDocument || l), this.$parent = e.parent(), this.isSVG = r.test(a.namespaceURI) && "svg" !== a.nodeName.toLowerCase(), this.panning = !1, this._buildTransform(), this._transform = !this.isSVG && b.cssProps.transform.replace(q, "-$1").toLowerCase(), this._buildTransition(), this.resetDimensions(); var f = b(), h = this; b.each(["$zoomIn", "$zoomOut", "$zoomRange", "$reset"], function (a, b) { h[b] = c[b] || f }), this.enable(), b.data(a, m, this) } var h = "over out down up move enter leave cancel".split(" "), i = b.extend({}, b.event.mouseHooks), j = {}; if (a.PointerEvent) b.each(h, function (a, c) { b.event.fixHooks[j[c] = "pointer" + c] = i }); else { var k = i.props; i.props = k.concat(["touches", "changedTouches", "targetTouches", "altKey", "ctrlKey", "metaKey", "shiftKey"]), i.filter = function (a, b) { var c, d = k.length; if (!b.pageX && b.touches && (c = b.touches[0])) for (; d--;) a[k[d]] = c[k[d]]; return a }, b.each(h, function (a, c) { if (2 > a) j[c] = "mouse" + c; else { var d = "touch" + ("down" === c ? "start" : "up" === c ? "end" : c); b.event.fixHooks[d] = i, j[c] = d + " mouse" + c } }) } b.pointertouch = j; var l = a.document, m = "__pz__", n = Array.prototype.slice, o = !!a.PointerEvent, p = function () { var a = l.createElement("input"); return a.setAttribute("oninput", "return"), "function" == typeof a.oninput }(), q = /([A-Z])/g, r = /^http:[\w\.\/]+svg$/, s = /^inline/, t = "(\\-?[\\d\\.e]+)", u = "\\,?\\s*", v = new RegExp("^matrix\\(" + t + u + t + u + t + u + t + u + t + u + t + "\\)$"); return e.prototype = { x: function (a) { var b = a instanceof f, c = this.elements, d = a.elements; return b && 3 === d.length ? new f(c[0] * d[0] + c[1] * d[1] + c[2] * d[2], c[3] * d[0] + c[4] * d[1] + c[5] * d[2], c[6] * d[0] + c[7] * d[1] + c[8] * d[2]) : d.length === c.length ? new e(c[0] * d[0] + c[1] * d[3] + c[2] * d[6], c[0] * d[1] + c[1] * d[4] + c[2] * d[7], c[0] * d[2] + c[1] * d[5] + c[2] * d[8], c[3] * d[0] + c[4] * d[3] + c[5] * d[6], c[3] * d[1] + c[4] * d[4] + c[5] * d[7], c[3] * d[2] + c[4] * d[5] + c[5] * d[8], c[6] * d[0] + c[7] * d[3] + c[8] * d[6], c[6] * d[1] + c[7] * d[4] + c[8] * d[7], c[6] * d[2] + c[7] * d[5] + c[8] * d[8]) : !1 }, inverse: function () { var a = 1 / this.determinant(), b = this.elements; return new e(a * (b[8] * b[4] - b[7] * b[5]), a * -(b[8] * b[1] - b[7] * b[2]), a * (b[5] * b[1] - b[4] * b[2]), a * -(b[8] * b[3] - b[6] * b[5]), a * (b[8] * b[0] - b[6] * b[2]), a * -(b[5] * b[0] - b[3] * b[2]), a * (b[7] * b[3] - b[6] * b[4]), a * -(b[7] * b[0] - b[6] * b[1]), a * (b[4] * b[0] - b[3] * b[1])) }, determinant: function () { var a = this.elements; return a[0] * (a[8] * a[4] - a[7] * a[5]) - a[3] * (a[8] * a[1] - a[7] * a[2]) + a[6] * (a[5] * a[1] - a[4] * a[2]) } }, f.prototype.e = e.prototype.e = function (a) { return this.elements[a] }, g.rmatrix = v, g.events = b.pointertouch, g.defaults = { eventNamespace: ".panzoom", transition: !0, cursor: "move", disablePan: !1, disableZoom: !1, increment: .3, minScale: .4, maxScale: 5, rangeStep: .05, duration: 200, easing: "ease-in-out", contain: !1 }, g.prototype = { constructor: g, instance: function () { return this }, enable: function () { this._initStyle(), this._bind(), this.disabled = !1 }, disable: function () { this.disabled = !0, this._resetStyle(), this._unbind() }, isDisabled: function () { return this.disabled }, destroy: function () { this.disable(), b.removeData(this.elem, m) }, resetDimensions: function () { var a = this.$parent; this.container = { width: a.innerWidth(), height: a.innerHeight() }; var c, d = a.offset(), e = this.elem, f = this.$elem; this.isSVG ? (c = e.getBoundingClientRect(), c = { left: c.left - d.left, top: c.top - d.top, width: c.width, height: c.height, margin: { left: 0, top: 0 } }) : c = { left: b.css(e, "left", !0) || 0, top: b.css(e, "top", !0) || 0, width: f.innerWidth(), height: f.innerHeight(), margin: { top: b.css(e, "marginTop", !0) || 0, left: b.css(e, "marginLeft", !0) || 0 } }, c.widthBorder = b.css(e, "borderLeftWidth", !0) + b.css(e, "borderRightWidth", !0) || 0, c.heightBorder = b.css(e, "borderTopWidth", !0) + b.css(e, "borderBottomWidth", !0) || 0, this.dimensions = c }, reset: function (a) { a = d(a); var b = this.setMatrix(this._origTransform, a); a.silent || this._trigger("reset", b) }, resetZoom: function (a) { a = d(a); var b = this.getMatrix(this._origTransform); a.dValue = b[3], this.zoom(b[0], a) }, resetPan: function (a) { var b = this.getMatrix(this._origTransform); this.pan(b[4], b[5], d(a)) }, setTransform: function (a) { for (var c = this.isSVG ? "attr" : "style", d = this.$set, e = d.length; e--;) b[c](d[e], "transform", a) }, getTransform: function (a) { var c = this.$set, d = c[0]; return a ? this.setTransform(a) : a = b[this.isSVG ? "attr" : "style"](d, "transform"), "none" === a || v.test(a) || this.setTransform(a = b.css(d, "transform")), a || "none" }, getMatrix: function (a) { var b = v.exec(a || this.getTransform()); return b && b.shift(), b || [1, 0, 0, 1, 0, 0] }, setMatrix: function (a, c) { if (!this.disabled) { c || (c = {}), "string" == typeof a && (a = this.getMatrix(a)); var d, e, f, g, h, i, j, k, l, m, n = +a[0], o = this.$parent, p = "undefined" != typeof c.contain ? c.contain : this.options.contain; return p && (d = this._checkDims(), e = this.container, l = d.width + d.widthBorder, m = d.height + d.heightBorder, f = (l * Math.abs(n) - e.width) / 2, g = (m * Math.abs(n) - e.height) / 2, j = d.left + d.margin.left, k = d.top + d.margin.top, "invert" === p ? (h = l > e.width ? l - e.width : 0, i = m > e.height ? m - e.height : 0, f += (e.width - l) / 2, g += (e.height - m) / 2, a[4] = Math.max(Math.min(a[4], f - j), -f - j - h), a[5] = Math.max(Math.min(a[5], g - k), -g - k - i + d.heightBorder)) : (g += d.heightBorder / 2, h = e.width > l ? e.width - l : 0, i = e.height > m ? e.height - m : 0, "center" === o.css("textAlign") && s.test(b.css(this.elem, "display")) ? h = 0 : f = g = 0, a[4] = Math.min(Math.max(a[4], f - j), -f - j + h), a[5] = Math.min(Math.max(a[5], g - k), -g - k + i))), "skip" !== c.animate && this.transition(!c.animate), c.range && this.$zoomRange.val(n), this.setTransform("matrix(" + a.join(",") + ")"), c.silent || this._trigger("change", a), a } }, isPanning: function () { return this.panning }, transition: function (a) { if (this._transition) for (var c = a || !this.options.transition ? "none" : this._transition, d = this.$set, e = d.length; e--;) b.style(d[e], "transition") !== c && b.style(d[e], "transition", c) }, pan: function (a, b, c) { if (!this.options.disablePan) { c || (c = {}); var d = c.matrix; d || (d = this.getMatrix()), c.relative && (a += +d[4], b += +d[5]), d[4] = a, d[5] = b, this.setMatrix(d, c), c.silent || this._trigger("pan", d[4], d[5]) } }, zoom: function (a, c) { "object" == typeof a ? (c = a, a = null) : c || (c = {}); var d = b.extend({}, this.options, c); if (!d.disableZoom) { var g = !1, h = d.matrix || this.getMatrix(); "number" != typeof a && (a = +h[0] + d.increment * (a ? -1 : 1), g = !0), a > d.maxScale ? a = d.maxScale : a < d.minScale && (a = d.minScale); var i = d.focal; if (i && !d.disablePan) { var j = this._checkDims(), k = i.clientX, l = i.clientY; this.isSVG || (k -= (j.width + j.widthBorder) / 2, l -= (j.height + j.heightBorder) / 2); var m = new f(k, l, 1), n = new e(h), o = this.parentOffset || this.$parent.offset(), p = new e(1, 0, o.left - this.$doc.scrollLeft(), 0, 1, o.top - this.$doc.scrollTop()), q = n.inverse().x(p.inverse().x(m)), r = a / h[0]; n = n.x(new e([r, 0, 0, r, 0, 0])), m = p.x(n.x(q)), h[4] = +h[4] + (k - m.e(0)), h[5] = +h[5] + (l - m.e(1)) } h[0] = a, h[3] = "number" == typeof d.dValue ? d.dValue : a, this.setMatrix(h, { animate: "boolean" == typeof d.animate ? d.animate : g, range: !d.noSetRange }), d.silent || this._trigger("zoom", h[0], d) } }, option: function (a, c) { var d; if (!a) return b.extend({}, this.options); if ("string" == typeof a) { if (1 === arguments.length) return void 0 !== this.options[a] ? this.options[a] : null; d = {}, d[a] = c } else d = a; this._setOptions(d) }, _setOptions: function (a) { b.each(a, b.proxy(function (a, c) { switch (a) { case "disablePan": this._resetStyle(); case "$zoomIn": case "$zoomOut": case "$zoomRange": case "$reset": case "disableZoom": case "onStart": case "onChange": case "onZoom": case "onPan": case "onEnd": case "onReset": case "eventNamespace": this._unbind() } switch (this.options[a] = c, a) { case "disablePan": this._initStyle(); case "$zoomIn": case "$zoomOut": case "$zoomRange": case "$reset": this[a] = c; case "disableZoom": case "onStart": case "onChange": case "onZoom": case "onPan": case "onEnd": case "onReset": case "eventNamespace": this._bind(); break; case "cursor": b.style(this.elem, "cursor", c); break; case "minScale": this.$zoomRange.attr("min", c); break; case "maxScale": this.$zoomRange.attr("max", c); break; case "rangeStep": this.$zoomRange.attr("step", c); break; case "startTransform": this._buildTransform(); break; case "duration": case "easing": this._buildTransition(); case "transition": this.transition(); break; case "$set": c instanceof b && c.length && (this.$set = c, this._initStyle(), this._buildTransform()) } }, this)) }, _initStyle: function () { var a = { "backface-visibility": "hidden", "transform-origin": this.isSVG ? "0 0" : "50% 50%" }; this.options.disablePan || (a.cursor = this.options.cursor), this.$set.css(a); var c = this.$parent; c.length && !b.nodeName(c[0], "body") && (a = { overflow: "hidden" }, "static" === c.css("position") && (a.position = "relative"), c.css(a)) }, _resetStyle: function () { this.$elem.css({ cursor: "", transition: "" }), this.$parent.css({ overflow: "", position: "" }) }, _bind: function () { var a = this, c = this.options, d = c.eventNamespace, e = o ? "pointerdown" + d : "touchstart" + d + " mousedown" + d, f = o ? "pointerup" + d : "touchend" + d + " click" + d, h = {}, i = this.$reset, j = this.$zoomRange; if (b.each(["Start", "Change", "Zoom", "Pan", "End", "Reset"], function () { var a = c["on" + this]; b.isFunction(a) && (h["panzoom" + this.toLowerCase() + d] = a) }), c.disablePan && c.disableZoom || (h[e] = function (b) { var d; ("touchstart" === b.type ? !(d = b.touches) || (1 !== d.length || c.disablePan) && 2 !== d.length : c.disablePan || 1 !== b.which) || (b.preventDefault(), b.stopPropagation(), a._startMove(b, d)) }), this.$elem.on(h), i.length && i.on(f, function (b) { b.preventDefault(), a.reset() }), j.length && j.attr({ step: c.rangeStep === g.defaults.rangeStep && j.attr("step") || c.rangeStep, min: c.minScale, max: c.maxScale }).prop({ value: this.getMatrix()[0] }), !c.disableZoom) { var k = this.$zoomIn, l = this.$zoomOut; k.length && l.length && (k.on(f, function (b) { b.preventDefault(), a.zoom() }), l.on(f, function (b) { b.preventDefault(), a.zoom(!0) })), j.length && (h = {}, h[(o ? "pointerdown" : "mousedown") + d] = function () { a.transition(!0) }, h[(p ? "input" : "change") + d] = function () { a.zoom(+this.value, { noSetRange: !0 }) }, j.on(h)) } }, _unbind: function () { this.$elem.add(this.$zoomIn).add(this.$zoomOut).add(this.$reset).off(this.options.eventNamespace) }, _buildTransform: function () { return this._origTransform = this.getTransform(this.options.startTransform) }, _buildTransition: function () { if (this._transform) { var a = this.options; this._transition = this._transform + " " + a.duration + "ms " + a.easing } }, _checkDims: function () { var a = this.dimensions; return a.width && a.height || this.resetDimensions(), this.dimensions }, _getDistance: function (a) { var b = a[0], c = a[1]; return Math.sqrt(Math.pow(Math.abs(c.clientX - b.clientX), 2) + Math.pow(Math.abs(c.clientY - b.clientY), 2)) }, _getMiddle: function (a) { var b = a[0], c = a[1]; return { clientX: (c.clientX - b.clientX) / 2 + b.clientX, clientY: (c.clientY - b.clientY) / 2 + b.clientY } }, _trigger: function (a) { "string" == typeof a && (a = "panzoom" + a), this.$elem.triggerHandler(a, [this].concat(n.call(arguments, 1))) }, _startMove: function (a, d) { var e, f, g, h, i, j, k, m, n = this, p = this.options, q = p.eventNamespace, r = this.getMatrix(), s = r.slice(0), t = +s[4], u = +s[5], v = { matrix: r, animate: "skip" }; o ? (f = "pointermove", g = "pointerup") : "touchstart" === a.type ? (f = "touchmove", g = "touchend") : (f = "mousemove", g = "mouseup"), f += q, g += q, this.transition(!0), this.panning = !0, this._trigger("start", a, d), d && 2 === d.length ? (h = this._getDistance(d), i = +r[0], j = this._getMiddle(d), e = function (a) { a.preventDefault(); var b = n._getMiddle(d = a.touches), c = n._getDistance(d) - h; n.zoom(c * (p.increment / 100) + i, { focal: b, matrix: r, animate: !1 }), n.pan(+r[4] + b.clientX - j.clientX, +r[5] + b.clientY - j.clientY, v), j = b }) : (k = a.pageX, m = a.pageY, e = function (a) { a.preventDefault(), n.pan(t + a.pageX - k, u + a.pageY - m, v) }), b(l).off(q).on(f, e).on(g, function (a) { a.preventDefault(), b(this).off(q), n.panning = !1, a.type = "panzoomend", n._trigger(a, r, !c(r, s)) }) } }, b.Panzoom = g, b.fn.panzoom = function (a) { var c, d, e, f; return "string" == typeof a ? (f = [], d = n.call(arguments, 1), this.each(function () { c = b.data(this, m), c ? "_" !== a.charAt(0) && "function" == typeof (e = c[a]) && void 0 !== (e = e.apply(c, d)) && f.push(e) : f.push(void 0) }), f.length ? 1 === f.length ? f[0] : f : this) : this.each(function () { new g(this, a) }) }, g });
//DZ 8may17: updating from older jsPDF
//JSPDF 1.3.4
!function (t, e) { "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.jspdf = e() }(this, function () {
"use strict"; var t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t }, e = (function () { function t(t) { this.value = t } function e(e) { function n(t, e) { return new Promise(function (n, i) { var s = { key: t, arg: e, resolve: n, reject: i, next: null }; a ? a = a.next = s : (o = a = s, r(t, e)) }) } function r(n, o) { try { var a = e[n](o), s = a.value; s instanceof t ? Promise.resolve(s.value).then(function (t) { r("next", t) }, function (t) { r("throw", t) }) : i(a.done ? "return" : "normal", a.value) } catch (t) { i("throw", t) } } function i(t, e) { switch (t) { case "return": o.resolve({ value: e, done: !0 }); break; case "throw": o.reject(e); break; default: o.resolve({ value: e, done: !1 }) } o = o.next, o ? r(o.key, o.arg) : a = null } var o, a; this._invoke = n, "function" != typeof e.return && (this.return = void 0) } return "function" == typeof Symbol && Symbol.asyncIterator && (e.prototype[Symbol.asyncIterator] = function () { return this }), e.prototype.next = function (t) { return this._invoke("next", t) }, e.prototype.throw = function (t) { return this._invoke("throw", t) }, e.prototype.return = function (t) { return this._invoke("return", t) }, { wrap: function (t) { return function () { return new e(t.apply(this, arguments)) } }, await: function (e) { return new t(e) } } }(), function (e) { function n(t) { var n = {}; this.subscribe = function (t, e, r) { if ("function" != typeof e) return !1; n.hasOwnProperty(t) || (n[t] = {}); var i = Math.random().toString(35); return n[t][i] = [e, !!r], i }, this.unsubscribe = function (t) { for (var e in n) if (n[e][t]) return delete n[e][t], !0; return !1 }, this.publish = function (r) { if (n.hasOwnProperty(r)) { var i = Array.prototype.slice.call(arguments, 1), o = []; for (var a in n[r]) { var s = n[r][a]; try { s[0].apply(t, i) } catch (t) { e.console && console.error("jsPDF PubSub Error", t.message, t) } s[1] && o.push(a) } o.length && o.forEach(this.unsubscribe) } } } function r(c, l, u, h) { var f = {}; "object" === ("undefined" == typeof c ? "undefined" : t(c)) && (f = c, c = f.orientation, l = f.unit || l, u = f.format || u, h = f.compress || f.compressPdf || h), l = l || "mm", u = u || "a4", c = ("" + (c || "P")).toLowerCase(); var d, p, g, m, w, y, v, b, x, k = (("" + u).toLowerCase(), !!h && "function" == typeof Uint8Array), _ = f.textColor || "0 g", C = f.drawColor || "0 G", A = f.fontSize || 16, S = f.lineHeight || 1.15, q = f.lineWidth || .200025, T = 2, P = !1, I = [], E = {}, O = {}, F = 0, R = [], B = [], D = [], j = [], z = [], N = 0, L = 0, M = 0, U = { title: "", subject: "", author: "", keywords: "", creator: "" }, H = {}, W = new n(H), X = function (t) { return t.toFixed(2) }, V = function (t) { return t.toFixed(3) }, Y = function (t) { return ("0" + parseInt(t)).slice(-2) }, G = function (t) { P ? R[m].push(t) : (M += t.length + 1, j.push(t)) }, J = function () { return T++, I[T] = M, G(T + " 0 obj"), T }, Q = function () { var t = 2 * R.length + 1; t += z.length; var e = { objId: t, content: "" }; return z.push(e), e }, K = function () { return T++, I[T] = function () { return M }, T }, $ = function (t) { I[t] = M }, Z = function (t) { G("stream"), G(t), G("endstream") }, tt = function () { var t, n, i, o, s, c, l, u, h, f = []; for (l = e.adler32cs || r.adler32cs, k && "undefined" == typeof l && (k = !1), t = 1; t <= F; t++) { if (f.push(J()), u = (w = D[t].width) * p, h = (y = D[t].height) * p, G("<>"), G("endobj"), n = R[t].join("\n"), J(), k) { for (i = [], o = n.length; o--;) i[o] = n.charCodeAt(o); c = l.from(n), s = new a(6), s.append(new Uint8Array(i)), n = s.flush(), i = new Uint8Array(n.length + 6), i.set(new Uint8Array([120, 156])), i.set(n, 2), i.set(new Uint8Array([255 & c, c >> 8 & 255, c >> 16 & 255, c >> 24 & 255]), n.length + 2), n = String.fromCharCode.apply(null, i), G("<>") } else G("<>"); Z(n), G("endobj") } I[1] = M, G("1 0 obj"), G("<>"), G("endobj"), W.publish("postPutPages") }, et = function (t) { t.objectNumber = J(), G("<>"), G("endobj") }, nt = function () { for (var t in E) E.hasOwnProperty(t) && et(E[t]) }, rt = function () { W.publish("putXobjectDict") }, it = function () { G("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"), G("/Font <<"); for (var t in E) E.hasOwnProperty(t) && G("..\\index.html" + t + " " + E[t].objectNumber + " 0 R"); G(">>"), G("/XObject <<"), rt(), G(">>") }, ot = function () { nt(), W.publish("putResources"), I[2] = M, G("2 0 obj"), G("<<"), it(), G(">>"), G("endobj"), W.publish("postPutResources") }, at = function () { W.publish("putAdditionalObjects"); for (var t = 0; t < z.length; t++) { var e = z[t]; I[e.objId] = M, G(e.objId + " 0 obj"), G(e.content), G("endobj") } T += z.length, W.publish("postPutAdditionalObjects") }, st = function (t, e, n) { O.hasOwnProperty(e) || (O[e] = {}), O[e][n] = t }, ct = function (t, e, n, r) { var i = "F" + (Object.keys(E).length + 1).toString(10), o = E[i] = { id: i, PostScriptName: t, fontName: e, fontStyle: n, encoding: r, metadata: {} }; return st(i, e, n), W.publish("addFont", o), i }, lt = function () { for (var t = "helvetica", e = "times", n = "courier", r = "normal", i = "bold", o = "italic", a = "bolditalic", s = "StandardEncoding", c = "zapfdingbats", l = [["Helvetica", t, r], ["Helvetica-Bold", t, i], ["Helvetica-Oblique", t, o], ["Helvetica-BoldOblique", t, a], ["Courier", n, r], ["Courier-Bold", n, i], ["Courier-Oblique", n, o], ["Courier-BoldOblique", n, a], ["Times-Roman", e, r], ["Times-Bold", e, i], ["Times-Italic", e, o], ["Times-BoldItalic", e, a], ["ZapfDingbats", c]], u = 0, h = l.length; u < h; u++) { var f = ct(l[u][0], l[u][1], l[u][2], s), d = l[u][0].split("-"); st(f, d[0], d[1] || "") } W.publish("addFonts", { fonts: E, dictionary: O }) }, ut = function (t) { return t.foo = function () { try { return t.apply(this, arguments) } catch (t) { var n = t.stack || ""; ~n.indexOf(" at ") && (n = n.split(" at ")[1]); var r = "Error in function " + n.split("\n")[0].split("<")[0] + ": " + t.message; if (!e.console) throw new Error(r); e.console.error(r, t), e.alert && alert(r) } }, t.foo.bar = t, t.foo }, ht = function (t, e) { var n, r, i, o, a, s, c, l, u; if (e = e || {}, i = e.sourceEncoding || "Unicode", a = e.outputEncoding, (e.autoencode || a) && E[d].metadata && E[d].metadata[i] && E[d].metadata[i].encoding && (o = E[d].metadata[i].encoding, !a && E[d].encoding && (a = E[d].encoding), !a && o.codePages && (a = o.codePages[0]), "string" == typeof a && (a = o[a]), a)) { for (c = !1, s = [], n = 0, r = t.length; n < r; n++) l = a[t.charCodeAt(n)], l ? s.push(String.fromCharCode(l)) : s.push(t[n]), s[n].charCodeAt(0) >> 8 && (c = !0); t = s.join("") } for (n = t.length; void 0 === c && 0 !== n;) t.charCodeAt(n - 1) >> 8 && (c = !0), n--; if (!c) return t; for (s = e.noBOM ? [] : [254, 255], n = 0, r = t.length; n < r; n++) { if (l = t.charCodeAt(n), u = l >> 8, u >> 8) throw new Error("Character at position " + n + " of string '" + t + "' exceeds 16bits. Cannot be encoded into UCS-2 BE"); s.push(u), s.push(l - (u << 8)) } return String.fromCharCode.apply(void 0, s) }, ft = function (t, e) { return ht(t, e).replace(/\\/g, "MS_7788.html").replace(/\(/g, "\\MS_7789.html").replace(http\\MS_24.html)/g, "\\)") }, dt = function () { G("..\\Producer (jsPDF.html " + r.version + ")"); for (var t in U) U.hasOwnProperty(t) && U[t] && G("..\\index.html" + t.substr(0, 1).toUpperCase() + t.substr(1) + " (" + ft(U[t]) + ")"); var e = new Date, n = e.getTimezoneOffset(), i = n < 0 ? "+" : "-", o = Math.floor(Math.abs(n / 60)), a = Math.abs(n % 60), s = [i, Y(o), "'", Y(a), "'"].join(""); G(["..\\CreationDate (D\\MS_7790.html", e.getFullYear(), Y(e.getMonth() + 1), Y(e.getDate()), Y(e.getHours()), Y(e.getMinutes()), Y(e.getSeconds()), s, ")"].join("")) }, pt = function () { switch (G("..\\Type \\Catalog.html"), G("..\\Pages 1 0 R.html"), b || (b = "fullwidth"), b) { case "fullwidth": G("/OpenAction [3 0 R /FitH null]"); break; case "fullheight": G("/OpenAction [3 0 R /FitV null]"); break; case "fullpage": G("/OpenAction [3 0 R /Fit]"); break; case "original": G("/OpenAction [3 0 R /XYZ null null 1]"); break; default: var t = "" + b; "%" === t.substr(t.length - 1) && (b = parseInt(b) / 100), "number" == typeof b && G("/OpenAction [3 0 R /XYZ null null " + X(b) + "]") } switch (x || (x = "continuous"), x) { case "continuous": G("..\\PageLayout \\OneColumn.html"); break; case "single": G("..\\PageLayout \\SinglePage.html"); break; case "two": case "twoleft": G("..\\PageLayout \\TwoColumnLeft.html"); break; case "tworight": G("..\\PageLayout \\TwoColumnRight.html") } v && G("..\\PageMode \\index.html" + v), W.publish("putCatalog") }, gt = function () { G("..\\Size.html " + (T + 1)), G("..\\Root.html " + T + " 0 R"), G("..\\Info.html " + (T - 1) + " 0 R") }, mt = function (t, e) { var n = "string" == typeof e && e.toLowerCase(); if ("string" == typeof t) { var r = t.toLowerCase(); s.hasOwnProperty(r) && (t = s[r][0] / p, e = s[r][1] / p) } if (Array.isArray(t) && (e = t[1], t = t[0]), n) { switch (n.substr(0, 1)) { case "l": e > t && (n = "s"); break; case "p": t > e && (n = "s") } "s" === n && (g = t, t = e, e = g) } P = !0, R[++F] = [], D[F] = { width: Number(t) || w, height: Number(e) || y }, B[F] = {}, vt(F) }, wt = function () { mt.apply(this, arguments), G(X(q * p) + " w"), G(C), 0 !== N && G(N + " J"), 0 !== L && G(L + " j"), W.publish("addPage", { pageNumber: F }) }, yt = function (t) { t > 0 && t <= F && (R.splice(t, 1), D.splice(t, 1), F--, m > F && (m = F), this.setPage(m)) }, vt = function (t) { t > 0 && t <= F && (m = t, w = D[t].width, y = D[t].height) }, bt = function (t, e) { var n; switch (t = void 0 !== t ? t : E[d].fontName, e = void 0 !== e ? e : E[d].fontStyle, void 0 !== t && (t = t.toLowerCase()), t) { case "sans-serif": case "verdana": case "arial": case "helvetica": t = "helvetica"; break; case "fixed": case "monospace": case "terminal": case "courier": t = "courier"; break; case "serif": case "cursive": case "fantasy": default: t = "times" } try { n = O[t][e] } catch (t) { } return n || (n = O.times[e], null == n && (n = O.times.normal)), n }, xt = function () { P = !1, T = 2, M = 0, j = [], I = [], z = [], W.publish("buildDocument"), G("%PDF-" + o), tt(), at(), ot(), J(), G("<<"), dt(), G(">>"), G("endobj"), J(), G("<<"), pt(), G(">>"), G("endobj"); var t, e = M, n = "0000000000"; for (G("xref"), G("0 " + (T + 1)), G(n + " 65535 f "), t = 1; t <= T; t++) { var r = I[t]; G("function" == typeof r ? (n + I[t]()).slice(-10) + " 00000 n " : (n + I[t]).slice(-10) + " 00000 n ") } return G("trailer"), G("<<"), gt(), G(">>"), G("startxref"), G("" + e), G("%%EOF"), P = !0, j.join("\n") }, kt = function (t) { var e = "S"; return "F" === t ? e = "f" : "FD" === t || "DF" === t ? e = "B" : "f" !== t && "f*" !== t && "B" !== t && "B*" !== t || (e = t), e }, _t = function () { for (var t = xt(), e = t.length, n = new ArrayBuffer(e), r = new Uint8Array(n) ; e--;) r[e] = t.charCodeAt(e); return n }, Ct = function () { return new Blob([_t()], { type: "application/pdf" }) }, At = ut(function (t, n) { var r = "dataur" === ("" + t).substr(0, 6) ? "data:application/pdf;base64," + btoa(xt()) : 0; switch (t) { case void 0: return xt(); case "save": if (navigator.getUserMedia && (void 0 === e.URL || void 0 === e.URL.createObjectURL)) return H.output("dataurlnewwindow"); i(Ct(), n), "function" == typeof i.unload && e.setTimeout && setTimeout(i.unload, 911); break; case "arraybuffer": return _t(); case "blob": return Ct(); case "bloburi": case "bloburl": return e.URL && e.URL.createObjectURL(Ct()) || void 0; case "datauristring": case "dataurlstring": return r; case "dataurlnewwindow": var o = e.open(r); if (o || "undefined" == typeof safari) return o; case "datauri": case "dataurl": return e.document.location.href = r; default: throw new Error('Output type "' + t + '" is not supported.') } }); switch (l) { case "pt": p = 1; break; case "mm": p = 72 / 25.4000508; break; case "cm": p = 72 / 2.54000508; break; case "in": p = 72; break; case "px": p = 96 / 72; break; case "pc": p = 12; break; case "em": p = 12; break; case "ex": p = 6; break; default: throw "Invalid unit: " + l } H.internal = { pdfEscape: ft, getStyle: kt, getFont: function () { return E[bt.apply(H, arguments)] }, getFontSize: function () { return A }, getLineHeight: function () { return A * S }, write: function (t) { G(1 === arguments.length ? t : Array.prototype.join.call(arguments, " ")) }, getCoordinateString: function (t) { return X(t * p) }, getVerticalCoordinateString: function (t) { return X((y - t) * p) }, collections: {}, newObject: J, newAdditionalObject: Q, newObjectDeferred: K, newObjectDeferredBegin: $, putStream: Z, events: W, scaleFactor: p, pageSize: { get width() { return w }, get height() { return y } }, output: function (t, e) { return At(t, e) }, getNumberOfPages: function () { return R.length - 1 }, pages: R, out: G, f2: X, getPageInfo: function (t) { var e = 2 * (t - 1) + 3; return { objId: e, pageNumber: t, pageContext: B[t] } }, getCurrentPageInfo: function () { var t = 2 * (m - 1) + 3; return { objId: t, pageNumber: m, pageContext: B[m] } }, getPDFVersion: function () { return o } }, H.addPage = function () { return wt.apply(this, arguments), this }, H.setPage = function () { return vt.apply(this, arguments), this }, H.insertPage = function (t) { return this.addPage(), this.movePage(m, t), this }, H.movePage = function (t, e) { if (t > e) { for (var n = R[t], r = D[t], i = B[t], o = t; o > e; o--) R[o] = R[o - 1], D[o] = D[o - 1], B[o] = B[o - 1]; R[e] = n, D[e] = r, B[e] = i, this.setPage(e) } else if (t < e) { for (var n = R[t], r = D[t], i = B[t], o = t; o < e; o++) R[o] = R[o + 1], D[o] = D[o + 1], B[o] = B[o + 1]; R[e] = n, D[e] = r, B[e] = i, this.setPage(e) } return this }, H.deletePage = function () { return yt.apply(this, arguments), this }, H.setDisplayMode = function (t, e, n) { b = t, x = e, v = n; var r = [void 0, null, "UseNone", "UseOutlines", "UseThumbs", "FullScreen"]; if (r.indexOf(n) == -1) throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' + n + '" is not recognized.'); return this }, H.text = function (t, e, n, r, i, o) { function a(t) { return t = t.split("\t").join(Array(f.TabLen || 9).join(" ")), ft(t, r) } "number" == typeof t && (g = n, n = e, e = t, t = g), "string" == typeof t && (t = t.match(/[\n\r]/) ? t.split(/\r\n|\r|\n/g) : [t]), "string" == typeof i && (o = i, i = null), "string" == typeof r && (o = r, r = null), "number" == typeof r && (i = r, r = null); var s, c = "", l = "Td"; if (i) { i *= Math.PI / 180; var u = Math.cos(i), h = Math.sin(i); c = [X(u), X(h), X(h * -1), X(u), ""].join(" "), l = "Tm" } r = r || {}, "noBOM" in r || (r.noBOM = !0), "autoencode" in r || (r.autoencode = !0); var m = "", w = this.internal.getCurrentPageInfo().pageContext; if (!0 === r.stroke ? w.lastTextWasStroke !== !0 && (m = "1 Tr\n", w.lastTextWasStroke = !0) : (w.lastTextWasStroke && (m = "0 Tr\n"), w.lastTextWasStroke = !1), "undefined" == typeof this._runningPageHeight && (this._runningPageHeight = 0), "string" == typeof t) t = a(t); else { if ("[object Array]" !== Object.prototype.toString.call(t)) throw new Error('Type of text must be string or Array. "' + t + '" is not recognized.'); for (var v = t.concat(), b = [], x = v.length; x--;) b.push(a(v.shift())); var k = Math.ceil((y - n - this._runningPageHeight) * p / (A * S)); if (0 <= k && k < b.length + 1, o) { var C, q, T, P = A * S, I = t.map(function (t) { return this.getStringUnitWidth(t) * A / p }, this); if (T = Math.max.apply(Math, I), "center" === o) C = e - T / 2, e -= I[0] / 2; else { if ("right" !== o) throw new Error('Unrecognized alignment option, use "center" or "right".'); C = e - T, e -= I[0] } q = e, t = b[0]; for (var E = 1, x = b.length; E < x; E++) { var O = T - I[E]; "center" === o && (O /= 2), t += ") Tj\n" + (C - q + O) + " -" + P + " Td (" + b[E], q = C + O } } else t = b.join(") Tj\nT* (") } var F; return s || (F = X((y - n) * p)), G("BT\n/" + d + " " + A + " Tf\n" + A * S + " TL\n" + m + _ + "\n" + c + X(e * p) + " " + F + " " + l + "\n(" + t + ") Tj\nET"), s && this.text(s, e, n), this }, H.lstext = function (t, e, n, r) { console.warn("jsPDF.lstext is deprecated"); for (var i = 0, o = t.length; i < o; i++, e += r) this.text(t[i], e, n); return this }, H.line = function (t, e, n, r) { return this.lines([[n - t, r - e]], t, e) }, H.clip = function () { G("W"), G("S") }, H.clip_fixed = function (t) { G("evenodd" === t ? "W*" : "W"), G("n") }, H.lines = function (t, e, n, r, i, o) { var a, s, c, l, u, h, f, d, m, w, v; for ("number" == typeof t && (g = n, n = e, e = t, t = g), r = r || [1, 1], G(V(e * p) + " " + V((y - n) * p) + " m "), a = r[0], s = r[1], l = t.length, w = e, v = n, c = 0; c < l; c++) u = t[c], 2 === u.length ? (w = u[0] * a + w, v = u[1] * s + v, G(V(w * p) + " " + V((y - v) * p) + " l")) : (h = u[0] * a + w, f = u[1] * s + v, d = u[2] * a + w, m = u[3] * s + v, w = u[4] * a + w, v = u[5] * s + v, G(V(h * p) + " " + V((y - f) * p) + " " + V(d * p) + " " + V((y - m) * p) + " " + V(w * p) + " " + V((y - v) * p) + " c")); return o && G(" h"), null !== i && G(kt(i)), this }, H.rect = function (t, e, n, r, i) { kt(i); return G([X(t * p), X((y - e) * p), X(n * p), X(-r * p), "re"].join(" ")), null !== i && G(kt(i)), this }, H.triangle = function (t, e, n, r, i, o, a) { return this.lines([[n - t, r - e], [i - n, o - r], [t - i, e - o]], t, e, [1, 1], a, !0), this }, H.roundedRect = function (t, e, n, r, i, o, a) { var s = 4 / 3 * (Math.SQRT2 - 1); return this.lines([[n - 2 * i, 0], [i * s, 0, i, o - o * s, i, o], [0, r - 2 * o], [0, o * s, -(i * s), o, -i, o], [-n + 2 * i, 0], [-(i * s), 0, -i, -(o * s), -i, -o], [0, -r + 2 * o], [0, -(o * s), i * s, -o, i, -o]], t + i, e, [1, 1], a), this }, H.ellipse = function (t, e, n, r, i) { var o = 4 / 3 * (Math.SQRT2 - 1) * n, a = 4 / 3 * (Math.SQRT2 - 1) * r; return G([X((t + n) * p), X((y - e) * p), "m", X((t + n) * p), X((y - (e - a)) * p), X((t + o) * p), X((y - (e - r)) * p), X(t * p), X((y - (e - r)) * p), "c"].join(" ")), G([X((t - o) * p), X((y - (e - r)) * p), X((t - n) * p), X((y - (e - a)) * p), X((t - n) * p), X((y - e) * p), "c"].join(" ")), G([X((t - n) * p), X((y - (e + a)) * p), X((t - o) * p), X((y - (e + r)) * p), X(t * p), X((y - (e + r)) * p), "c"].join(" ")), G([X((t + o) * p), X((y - (e + r)) * p), X((t + n) * p), X((y - (e + a)) * p), X((t + n) * p), X((y - e) * p), "c"].join(" ")), null !== i && G(kt(i)), this }, H.circle = function (t, e, n, r) { return this.ellipse(t, e, n, n, r) }, H.setProperties = function (t) { for (var e in U) U.hasOwnProperty(e) && t[e] && (U[e] = t[e]); return this }, H.setFontSize = function (t) { return A = t, this }, H.setFont = function (t, e) { return d = bt(t, e), this }, H.setFontStyle = H.setFontType = function (t) { return d = bt(void 0, t), this }, H.getFontList = function () { var t, e, n, r = {}; for (t in O) if (O.hasOwnProperty(t)) { r[t] = n = []; for (e in O[t]) O[t].hasOwnProperty(e) && n.push(e) } return r }, H.addFont = function (t, e, n) { ct(t, e, n, "StandardEncoding") }, H.setLineWidth = function (t) { return G((t * p).toFixed(2) + " w"), this }, H.setDrawColor = function (t, e, n, r) { var i; return i = void 0 === e || void 0 === r && t === e === n ? "string" == typeof t ? t + " G" : X(t / 255) + " G" : void 0 === r ? "string" == typeof t ? [t, e, n, "RG"].join(" ") : [X(t / 255), X(e / 255), X(n / 255), "RG"].join(" ") : "string" == typeof t ? [t, e, n, r, "K"].join(" ") : [X(t), X(e), X(n), X(r), "K"].join(" "), G(i), this }, H.setFillColor = function (e, n, r, i) { var o; return void 0 === n || void 0 === i && e === n === r ? o = "string" == typeof e ? e + " g" : X(e / 255) + " g" : void 0 === i || "object" === ("undefined" == typeof i ? "undefined" : t(i)) ? (o = "string" == typeof e ? [e, n, r, "rg"].join(" ") : [X(e / 255), X(n / 255), X(r / 255), "rg"].join(" "), i && 0 === i.a && (o = ["255", "255", "255", "rg"].join(" "))) : o = "string" == typeof e ? [e, n, r, i, "k"].join(" ") : [X(e), X(n), X(r), X(i), "k"].join(" "), G(o), this }, H.setTextColor = function (t, e, n) { if ("string" == typeof t && /^#[0-9A-Fa-f]{6}$/.test(t)) { var r = parseInt(t.substr(1), 16); t = r >> 16 & 255, e = r >> 8 & 255, n = 255 & r } return _ = 0 === t && 0 === e && 0 === n || "undefined" == typeof e ? V(t / 255) + " g" : [V(t / 255), V(e / 255), V(n / 255), "rg"].join(" "), this }, H.CapJoinStyles = { 0: 0, butt: 0, but: 0, miter: 0, 1: 1, round: 1, rounded: 1, circle: 1, 2: 2, projecting: 2, project: 2, square: 2, bevel: 2 }, H.setLineCap = function (t) { var e = this.CapJoinStyles[t]; if (void 0 === e) throw new Error("Line cap style of '" + t + "' is not recognized. See or extend .CapJoinStyles property for valid styles"); return N = e, G(e + " J"), this }, H.setLineJoin = function (t) { var e = this.CapJoinStyles[t]; if (void 0 === e) throw new Error("Line join style of '" + t + "' is not recognized. See or extend .CapJoinStyles property for valid styles"); return L = e, G(e + " j"), this }, H.output = At, H.save = function (t) { H.output("save", t) }; for (var St in r.API) r.API.hasOwnProperty(St) && ("events" === St && r.API.events.length ? !function (t, e) { var n, r, i; for (i = e.length - 1; i !== -1; i--) n = e[i][0], r = e[i][1], t.subscribe.apply(t, [n].concat("function" == typeof r ? [r] : r)) }(W, r.API.events) : H[St] = r.API[St]); return lt(), d = "F1", wt(u, c), W.publish("initialized"), H } var o = "1.3", s = { a0: [2383.94, 3370.39], a1: [1683.78, 2383.94], a2: [1190.55, 1683.78], a3: [841.89, 1190.55], a4: [595.28, 841.89], a5: [419.53, 595.28], a6: [297.64, 419.53], a7: [209.76, 297.64], a8: [147.4, 209.76], a9: [104.88, 147.4], a10: [73.7, 104.88], b0: [2834.65, 4008.19], b1: [2004.09, 2834.65], b2: [1417.32, 2004.09], b3: [1000.63, 1417.32], b4: [708.66, 1000.63], b5: [498.9, 708.66], b6: [354.33, 498.9], b7: [249.45, 354.33], b8: [175.75, 249.45], b9: [124.72, 175.75], b10: [87.87, 124.72], c0: [2599.37, 3676.54], c1: [1836.85, 2599.37], c2: [1298.27, 1836.85], c3: [918.43, 1298.27], c4: [649.13, 918.43], c5: [459.21, 649.13], c6: [323.15, 459.21], c7: [229.61, 323.15], c8: [161.57, 229.61], c9: [113.39, 161.57], c10: [79.37, 113.39], dl: [311.81, 623.62], letter: [612, 792], "government-letter": [576, 756], legal: [612, 1008], "junior-legal": [576, 360], ledger: [1224, 792], tabloid: [792, 1224], "credit-card": [153, 243] }; return r.API = { events: [] }, r.version = "1.x-master", "function" == typeof define && define.amd ? define("jsPDF", function () { return r }) : "undefined" != typeof module && module.exports ? module.exports = r : e.jsPDF = r, r }("undefined" != typeof self && self || "undefined" != typeof window && window || void 0));/**
* jsPDF AcroForm Plugin
* Copyright (c) 2016 Alexander Weidt, https://github.com/BiggA94
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(window.AcroForm = function (t) { var n = window.AcroForm; n.scale = function (t) { return t * (r.internal.scaleFactor / 1) }, n.antiScale = function (t) { return 1 / r.internal.scaleFactor * t }; var r = { fields: [], xForms: [], acroFormDictionaryRoot: null, printedOut: !1, internal: null }; e.API.acroformPlugin = r; var i = function () { for (var t in this.acroformPlugin.acroFormDictionaryRoot.Fields) { var e = this.acroformPlugin.acroFormDictionaryRoot.Fields[t]; e.hasAnnotation && a.call(this, e) } }, o = function () { if (this.acroformPlugin.acroFormDictionaryRoot) throw new Error("Exception while creating AcroformDictionary"); this.acroformPlugin.acroFormDictionaryRoot = new n.AcroFormDictionary, this.acroformPlugin.internal = this.internal, this.acroformPlugin.acroFormDictionaryRoot._eventID = this.internal.events.subscribe("postPutResources", l), this.internal.events.subscribe("buildDocument", i), this.internal.events.subscribe("putCatalog", c), this.internal.events.subscribe("postPutPages", u) }, a = function (t) { var n = { type: "reference", object: t }; e.API.annotationPlugin.annotations[this.internal.getPageInfo(t.page).pageNumber].push(n) }, s = function (t) { this.acroformPlugin.printedOut && (this.acroformPlugin.printedOut = !1, this.acroformPlugin.acroFormDictionaryRoot = null), this.acroformPlugin.acroFormDictionaryRoot || o.call(this), this.acroformPlugin.acroFormDictionaryRoot.Fields.push(t) }, c = function () { "undefined" != typeof this.acroformPlugin.acroFormDictionaryRoot ? this.internal.write("..\\AcroForm.html " + this.acroformPlugin.acroFormDictionaryRoot.objId + " 0 R") : console.log("Root missing...") }, l = function () { this.internal.events.unsubscribe(this.acroformPlugin.acroFormDictionaryRoot._eventID), delete this.acroformPlugin.acroFormDictionaryRoot._eventID, this.acroformPlugin.printedOut = !0 }, u = function (t) { var e = !t; t || (this.internal.newObjectDeferredBegin(this.acroformPlugin.acroFormDictionaryRoot.objId), this.internal.out(this.acroformPlugin.acroFormDictionaryRoot.getString())); var t = t || this.acroformPlugin.acroFormDictionaryRoot.Kids; for (var r in t) { var i = t[r], o = i.Rect; i.Rect && (i.Rect = n.internal.calculateCoordinates.call(this, i.Rect)), this.internal.newObjectDeferredBegin(i.objId); var a = ""; if (a += i.objId + " 0 obj\n", a += "<<\n" + i.getContent(), i.Rect = o, i.hasAppearanceStream && !i.appearanceStreamContent) { var s = n.internal.calculateAppearanceStream.call(this, i); a += "/AP << /N " + s + " >>\n", this.acroformPlugin.xForms.push(s) } if (i.appearanceStreamContent) { a += "/AP << "; for (var c in i.appearanceStreamContent) { var l = i.appearanceStreamContent[c]; if (a += "..\\index.html" + c + " ", a += "<< ", Object.keys(l).length >= 1 || Array.isArray(l)) for (var r in l) { var u = l[r]; "function" == typeof u && (u = u.call(this, i)), a += "/" + r + " " + u + " ", this.acroformPlugin.xForms.indexOf(u) >= 0 || this.acroformPlugin.xForms.push(u) } else { var u = l; "function" == typeof u && (u = u.call(this, i)), a += "/" + r + " " + u + " \n", this.acroformPlugin.xForms.indexOf(u) >= 0 || this.acroformPlugin.xForms.push(u) } a += " >>\n" } a += ">>\n" } a += ">>\nendobj\n", this.internal.out(a) } e && h.call(this, this.acroformPlugin.xForms) }, h = function (t) { for (var e in t) { var n = e, r = t[e]; this.internal.newObjectDeferredBegin(r && r.objId); var i = ""; i += r ? r.getString() : "", this.internal.out(i), delete t[n] } }; t.addField = function (t) { return t instanceof n.TextField ? d.call(this, t) : t instanceof n.ChoiceField ? p.call(this, t) : t instanceof n.Button ? f.call(this, t) : t instanceof n.ChildClass ? s.call(this, t) : t && s.call(this, t), t.page = this.acroformPlugin.internal.getCurrentPageInfo().pageNumber, this }; var f = function (t) { var t = t || new n.Field; t.FT = "..\\Btn.html"; var e = t.Ff || 0; t.pushbutton && (e = n.internal.setBitPosition(e, 17), delete t.pushbutton), t.radio && (e = n.internal.setBitPosition(e, 16), delete t.radio), t.noToggleToOff && (e = n.internal.setBitPosition(e, 15)), t.Ff = e, s.call(this, t) }, d = function (t) { var t = t || new n.Field; t.FT = "..\\Tx.html"; var e = t.Ff || 0; t.multiline && (e = 4096 | e), t.password && (e = 8192 | e), t.fileSelect && (e |= 1 << 20), t.doNotSpellCheck && (e |= 1 << 22), t.doNotScroll && (e |= 1 << 23), t.Ff = t.Ff || e, s.call(this, t) }, p = function (t) { var e = t || new n.Field; e.FT = "..\\Ch.html"; var r = e.Ff || 0; e.combo && (r = n.internal.setBitPosition(r, 18), delete e.combo), e.edit && (r = n.internal.setBitPosition(r, 19), delete e.edit), e.sort && (r = n.internal.setBitPosition(r, 20), delete e.sort), e.multiSelect && this.internal.getPDFVersion() >= 1.4 && (r = n.internal.setBitPosition(r, 22), delete e.multiSelect), e.doNotSpellCheck && this.internal.getPDFVersion() >= 1.4 && (r = n.internal.setBitPosition(r, 23), delete e.doNotSpellCheck), e.Ff = r, s.call(this, e) } })(e.API); var n = window.AcroForm; n.internal = {}, n.createFormXObject = function (t) { var e = new n.FormXObject, r = n.Appearance.internal.getHeight(t) || 0, i = n.Appearance.internal.getWidth(t) || 0; return e.BBox = [0, 0, i, r], e }, n.Appearance = { CheckBox: { createAppearanceStream: function () { var t = { N: { On: n.Appearance.CheckBox.YesNormal }, D: { On: n.Appearance.CheckBox.YesPushDown, Off: n.Appearance.CheckBox.OffPushDown } }; return t }, createMK: function () { return "<< /CA (3)>>" }, YesPushDown: function (t) { var e = n.createFormXObject(t), r = ""; t.Q = 1; var i = n.internal.calculateX(t, "3", "ZapfDingbats", 50); return r += "0.749023 g\n 0 0 " + n.Appearance.internal.getWidth(t) + " " + n.Appearance.internal.getHeight(t) + " re\n f\n BMC\n q\n 0 0 1 rg\n /F13 " + i.fontSize + " Tf 0 g\n BT\n", r += i.text, r += "ET\n Q\n EMC\n", e.stream = r, e }, YesNormal: function (t) { var e = n.createFormXObject(t), r = ""; t.Q = 1; var i = n.internal.calculateX(t, "3", "ZapfDingbats", .9 * n.Appearance.internal.getHeight(t)); return r += "1 g\n0 0 " + n.Appearance.internal.getWidth(t) + " " + n.Appearance.internal.getHeight(t) + " re\nf\nq\n0 0 1 rg\n0 0 " + (n.Appearance.internal.getWidth(t) - 1) + " " + (n.Appearance.internal.getHeight(t) - 1) + " re\nW\nn\n0 g\nBT\n/F13 " + i.fontSize + " Tf 0 g\n", r += i.text, r += "ET\n Q\n", e.stream = r, e }, OffPushDown: function (t) { var e = n.createFormXObject(t), r = ""; return r += "0.749023 g\n 0 0 " + n.Appearance.internal.getWidth(t) + " " + n.Appearance.internal.getHeight(t) + " re\n f\n", e.stream = r, e } }, RadioButton: { Circle: { createAppearanceStream: function (t) { var e = { D: { Off: n.Appearance.RadioButton.Circle.OffPushDown }, N: {} }; return e.N[t] = n.Appearance.RadioButton.Circle.YesNormal, e.D[t] = n.Appearance.RadioButton.Circle.YesPushDown, e }, createMK: function () { return "<< /CA (l)>>" }, YesNormal: function (t) { var e = n.createFormXObject(t), r = "", i = n.Appearance.internal.getWidth(t) <= n.Appearance.internal.getHeight(t) ? n.Appearance.internal.getWidth(t) / 4 : n.Appearance.internal.getHeight(t) / 4; i *= .9; var o = n.Appearance.internal.Bezier_C; return r += "q\n1 0 0 1 " + n.Appearance.internal.getWidth(t) / 2 + " " + n.Appearance.internal.getHeight(t) / 2 + " cm\n" + i + " 0 m\n" + i + " " + i * o + " " + i * o + " " + i + " 0 " + i + " c\n-" + i * o + " " + i + " -" + i + " " + i * o + " -" + i + " 0 c\n-" + i + " -" + i * o + " -" + i * o + " -" + i + " 0 -" + i + " c\n" + i * o + " -" + i + " " + i + " -" + i * o + " " + i + " 0 c\nf\nQ\n", e.stream = r, e }, YesPushDown: function (t) { var e = n.createFormXObject(t), r = "", i = n.Appearance.internal.getWidth(t) <= n.Appearance.internal.getHeight(t) ? n.Appearance.internal.getWidth(t) / 4 : n.Appearance.internal.getHeight(t) / 4; i *= .9; var o = 2 * i, a = o * n.Appearance.internal.Bezier_C, s = i * n.Appearance.internal.Bezier_C; return r += "0.749023 g\n q\n 1 0 0 1 " + n.Appearance.internal.getWidth(t) / 2 + " " + n.Appearance.internal.getHeight(t) / 2 + " cm\n" + o + " 0 m\n" + o + " " + a + " " + a + " " + o + " 0 " + o + " c\n-" + a + " " + o + " -" + o + " " + a + " -" + o + " 0 c\n-" + o + " -" + a + " -" + a + " -" + o + " 0 -" + o + " c\n" + a + " -" + o + " " + o + " -" + a + " " + o + " 0 c\n f\n Q\n 0 g\n q\n 1 0 0 1 " + n.Appearance.internal.getWidth(t) / 2 + " " + n.Appearance.internal.getHeight(t) / 2 + " cm\n" + i + " 0 m\n" + i + " " + s + " " + s + " " + i + " 0 " + i + " c\n-" + s + " " + i + " -" + i + " " + s + " -" + i + " 0 c\n-" + i + " -" + s + " -" + s + " -" + i + " 0 -" + i + " c\n" + s + " -" + i + " " + i + " -" + s + " " + i + " 0 c\n f\n Q\n", e.stream = r, e }, OffPushDown: function (t) { var e = n.createFormXObject(t), r = "", i = n.Appearance.internal.getWidth(t) <= n.Appearance.internal.getHeight(t) ? n.Appearance.internal.getWidth(t) / 4 : n.Appearance.internal.getHeight(t) / 4; i *= .9; var o = 2 * i, a = o * n.Appearance.internal.Bezier_C; return r += "0.749023 g\n q\n 1 0 0 1 " + n.Appearance.internal.getWidth(t) / 2 + " " + n.Appearance.internal.getHeight(t) / 2 + " cm\n" + o + " 0 m\n" + o + " " + a + " " + a + " " + o + " 0 " + o + " c\n-" + a + " " + o + " -" + o + " " + a + " -" + o + " 0 c\n-" + o + " -" + a + " -" + a + " -" + o + " 0 -" + o + " c\n" + a + " -" + o + " " + o + " -" + a + " " + o + " 0 c\n f\n Q\n", e.stream = r, e } }, Cross: { createAppearanceStream: function (t) { var e = { D: { Off: n.Appearance.RadioButton.Cross.OffPushDown }, N: {} }; return e.N[t] = n.Appearance.RadioButton.Cross.YesNormal, e.D[t] = n.Appearance.RadioButton.Cross.YesPushDown, e }, createMK: function () { return "<< /CA (8)>>" }, YesNormal: function (t) { var e = n.createFormXObject(t), r = "", i = n.Appearance.internal.calculateCross(t); return r += "q\n 1 1 " + (n.Appearance.internal.getWidth(t) - 2) + " " + (n.Appearance.internal.getHeight(t) - 2) + " re\n W\n n\n " + i.x1.x + " " + i.x1.y + " m\n " + i.x2.x + " " + i.x2.y + " l\n " + i.x4.x + " " + i.x4.y + " m\n " + i.x3.x + " " + i.x3.y + " l\n s\n Q\n", e.stream = r, e }, YesPushDown: function (t) { var e = n.createFormXObject(t), r = n.Appearance.internal.calculateCross(t), i = ""; return i += "0.749023 g\n 0 0 " + n.Appearance.internal.getWidth(t) + " " + n.Appearance.internal.getHeight(t) + " re\n f\n q\n 1 1 " + (n.Appearance.internal.getWidth(t) - 2) + " " + (n.Appearance.internal.getHeight(t) - 2) + " re\n W\n n\n " + r.x1.x + " " + r.x1.y + " m\n " + r.x2.x + " " + r.x2.y + " l\n " + r.x4.x + " " + r.x4.y + " m\n " + r.x3.x + " " + r.x3.y + " l\n s\n Q\n", e.stream = i, e }, OffPushDown: function (t) { var e = n.createFormXObject(t), r = ""; return r += "0.749023 g\n 0 0 " + n.Appearance.internal.getWidth(t) + " " + n.Appearance.internal.getHeight(t) + " re\n f\n", e.stream = r, e } } }, createDefaultAppearanceStream: function (t) { var e = ""; return e += "/Helv 0 Tf 0 g" } }, n.Appearance.internal = { Bezier_C: .551915024494, calculateCross: function (t) { var e = function (t, e) { return t > e ? e : t }, r = n.Appearance.internal.getWidth(t), i = n.Appearance.internal.getHeight(t), o = e(r, i), a = { x1: { x: (r - o) / 2, y: (i - o) / 2 + o }, x2: { x: (r - o) / 2 + o, y: (i - o) / 2 }, x3: { x: (r - o) / 2, y: (i - o) / 2 }, x4: { x: (r - o) / 2 + o, y: (i - o) / 2 + o } }; return a } }, n.Appearance.internal.getWidth = function (t) { return t.Rect[2] }, n.Appearance.internal.getHeight = function (t) { return t.Rect[3] }, n.internal.inherit = function (t, e) { Object.create || function (t) { var e = function () { }; return e.prototype = t, new e }; t.prototype = Object.create(e.prototype), t.prototype.constructor = t }, n.internal.arrayToPdfArray = function (t) { if (Array.isArray(t)) { var e = " ["; for (var n in t) { var r = t[n].toString(); e += r, e += n < t.length - 1 ? " " : "" } return e += "]" } }, n.internal.toPdfString = function (t) { return t = t || "", 0 !== t.indexOf("(") && (t = "(" + t), ")" != t.substring(t.length - 1) && (t += "("), t }, n.PDFObject = function () { var t; Object.defineProperty(this, "objId", { get: function () { return t || (this.internal ? t = this.internal.newObjectDeferred() : e.API.acroformPlugin.internal && (t = e.API.acroformPlugin.internal.newObjectDeferred())), t || console.log("Couldn't create Object ID"), t }, configurable: !1 }) }, n.PDFObject.prototype.toString = function () { return this.objId + " 0 R" }, n.PDFObject.prototype.getString = function () { var t = this.objId + " 0 obj\n<<", e = this.getContent(); return t += e + ">>\n", this.stream && (t += "stream\n", t += this.stream, t += "endstream\n"), t += "endobj\n" }, n.PDFObject.prototype.getContent = function () { var t = function (t) { var e = "", r = Object.keys(t).filter(function (t) { return "content" != t && "appearanceStreamContent" != t && "_" != t.substring(0, 1) }); for (var i in r) { var o = r[i], a = t[o]; a && (e += Array.isArray(a) ? "/" + o + " " + n.internal.arrayToPdfArray(a) + "\n" : a instanceof n.PDFObject ? "/" + o + " " + a.objId + " 0 R\n" : "/" + o + " " + a + "\n") } return e }, e = ""; return e += t(this) }, n.FormXObject = function () { n.PDFObject.call(this), this.Type = "..\\XObject.html", this.Subtype = "..\\Form.html", this.FormType = 1, this.BBox, this.Matrix, this.Resources = "2 0 R", this.PieceInfo; var t; Object.defineProperty(this, "Length", { enumerable: !0, get: function () { return void 0 !== t ? t.length : 0 } }), Object.defineProperty(this, "stream", { enumerable: !1, set: function (e) { t = e }, get: function () { return t ? t : null } }) }, n.internal.inherit(n.FormXObject, n.PDFObject), n.AcroFormDictionary = function () { n.PDFObject.call(this); var t = []; Object.defineProperty(this, "Kids", { enumerable: !1, configurable: !0, get: function () { return t.length > 0 ? t : void 0 } }), Object.defineProperty(this, "Fields", { enumerable: !0, configurable: !0, get: function () { return t } }), this.DA }, n.internal.inherit(n.AcroFormDictionary, n.PDFObject), n.Field = function () { n.PDFObject.call(this); var t; Object.defineProperty(this, "Rect", { enumerable: !0, configurable: !1, get: function () { if (t) { var e = t; return e } }, set: function (e) { t = e } }); var e = ""; Object.defineProperty(this, "FT", { enumerable: !0, set: function (t) { e = t }, get: function () { return e } }); var r; Object.defineProperty(this, "T", { enumerable: !0, configurable: !1, set: function (t) { r = t }, get: function () { if (!r || r.length < 1) { if (this instanceof n.ChildClass) return; return "(FieldObject" + n.Field.FieldNum++ + ")" } return "(" == r.substring(0, 1) && r.substring(r.length - 1) ? r : "(" + r + ")" } }); var i; Object.defineProperty(this, "DA", { enumerable: !0, get: function () { if (i) return "(" + i + ")" }, set: function (t) { i = t } }); var o; Object.defineProperty(this, "DV", { enumerable: !0, configurable: !0, get: function () { if (o) return o }, set: function (t) { o = t } }), Object.defineProperty(this, "Type", { enumerable: !0, get: function () { return this.hasAnnotation ? "..\\Annot.html" : null } }), Object.defineProperty(this, "Subtype", { enumerable: !0, get: function () { return this.hasAnnotation ? "..\\Widget.html" : null } }), this.BG, Object.defineProperty(this, "hasAnnotation", { enumerable: !1, get: function () { return !!(this.Rect || this.BC || this.BG) } }), Object.defineProperty(this, "hasAppearanceStream", { enumerable: !1, configurable: !0, writable: !0 }), Object.defineProperty(this, "page", { enumerable: !1, configurable: !0, writable: !0 }) }, n.Field.FieldNum = 0, n.internal.inherit(n.Field, n.PDFObject), n.ChoiceField = function () { n.Field.call(this), this.FT = "..\\Ch.html", this.Opt = [], this.V = "()", this.TI = 0, this.combo = !1, Object.defineProperty(this, "edit", { enumerable: !0, set: function (t) { 1 == t ? (this._edit = !0, this.combo = !0) : this._edit = !1 }, get: function () { return !!this._edit && this._edit }, configurable: !1 }), this.hasAppearanceStream = !0, Object.defineProperty(this, "V", { get: function () { n.internal.toPdfString() } }) }, n.internal.inherit(n.ChoiceField, n.Field), window.ChoiceField = n.ChoiceField, n.ListBox = function () { n.ChoiceField.call(this) }, n.internal.inherit(n.ListBox, n.ChoiceField), window.ListBox = n.ListBox, n.ComboBox = function () { n.ListBox.call(this), this.combo = !0 }, n.internal.inherit(n.ComboBox, n.ListBox), window.ComboBox = n.ComboBox, n.EditBox = function () { n.ComboBox.call(this), this.edit = !0 }, n.internal.inherit(n.EditBox, n.ComboBox), window.EditBox = n.EditBox, n.Button = function () { n.Field.call(this), this.FT = "..\\Btn.html" }, n.internal.inherit(n.Button, n.Field), window.Button = n.Button, n.PushButton = function () { n.Button.call(this), this.pushbutton = !0 }, n.internal.inherit(n.PushButton, n.Button), window.PushButton = n.PushButton, n.RadioButton = function () { n.Button.call(this), this.radio = !0; var t = []; Object.defineProperty(this, "Kids", { enumerable: !0, get: function () { if (t.length > 0) return t } }), Object.defineProperty(this, "__Kids", { get: function () { return t } }); var e; Object.defineProperty(this, "noToggleToOff", { enumerable: !1, get: function () { return e }, set: function (t) { e = t } }) }, n.internal.inherit(n.RadioButton, n.Button), window.RadioButton = n.RadioButton, n.ChildClass = function (t, e) { n.Field.call(this), this.Parent = t, this._AppearanceType = n.Appearance.RadioButton.Circle, this.appearanceStreamContent = this._AppearanceType.createAppearanceStream(e), this.F = n.internal.setBitPosition(this.F, 3, 1), this.MK = this._AppearanceType.createMK(), this.AS = "..\\Off.html", this._Name = e }, n.internal.inherit(n.ChildClass, n.Field), n.RadioButton.prototype.setAppearance = function (t) { if (!("createAppearanceStream" in t && "createMK" in t)) return void console.log("Couldn't assign Appearance to RadioButton. Appearance was Invalid!"); for (var e in this.__Kids) { var n = this.__Kids[e]; n.appearanceStreamContent = t.createAppearanceStream(n._Name), n.MK = t.createMK() } }, n.RadioButton.prototype.createOption = function (t) { var r = this, i = (this.__Kids.length, new n.ChildClass(r, t)); return this.__Kids.push(i), e.API.addField(i), i }, n.CheckBox = function () { Button.call(this), this.appearanceStreamContent = n.Appearance.CheckBox.createAppearanceStream(), this.MK = n.Appearance.CheckBox.createMK(), this.AS = "..\\On.html", this.V = "..\\On.html" }, n.internal.inherit(n.CheckBox, n.Button), window.CheckBox = n.CheckBox, n.TextField = function () { n.Field.call(this), this.DA = n.Appearance.createDefaultAppearanceStream(), this.F = 4; var t; Object.defineProperty(this, "V", { get: function () { return t ? "(" + t + ")" : t }, enumerable: !0, set: function (e) { t = e } }); var e; Object.defineProperty(this, "DV", { get: function () { return e ? "(" + e + ")" : e }, enumerable: !0, set: function (t) { e = t } }); var r = !1; Object.defineProperty(this, "multiline", { enumerable: !1, get: function () { return r }, set: function (t) { r = t } }); var i = !1; Object.defineProperty(this, "MaxLen", { enumerable: !0, get: function () { return i }, set: function (t) { i = t } }), Object.defineProperty(this, "hasAppearanceStream", { enumerable: !1, get: function () { return this.V || this.DV } }) }, n.internal.inherit(n.TextField, n.Field), window.TextField = n.TextField, n.PasswordField = function () { TextField.call(this), Object.defineProperty(this, "password", { value: !0, enumerable: !1, configurable: !1, writable: !1 }) }, n.internal.inherit(n.PasswordField, n.TextField), window.PasswordField = n.PasswordField, n.internal.calculateFontSpace = function (t, e, r) { var r = r || "helvetica", i = n.internal.calculateFontSpace.canvas || (n.internal.calculateFontSpace.canvas = document.createElement("canvas")), o = i.getContext("2d"); o.save(); var a = e + " " + r; o.font = a; var s = o.measureText(t); o.fontcolor = "black"; var o = i.getContext("2d"); s.height = 1.5 * o.measureText("3").width, o.restore(); s.width; return s }, n.internal.calculateX = function (t, e, r, i) { var i = i || 12, r = r || "helvetica", o = { text: "", fontSize: "" }; e = "(" == e.substr(0, 1) ? e.substr(1) : e, e = ")" == e.substr(e.length - 1) ? e.substr(0, e.length - 1) : e; var a = e.split(" "), s = i, c = 2, l = 2, u = n.Appearance.internal.getHeight(t) || 0; u = u < 0 ? -u : u; var h = n.Appearance.internal.getWidth(t) || 0; h = h < 0 ? -h : h; var f = function (t, e, i) { if (t + 1 < a.length) { var o = e + " " + a[t + 1], s = n.internal.calculateFontSpace(o, i + "px", r).width, c = h - 2 * l; return s <= c } return !1 }; s++; t: for (; ;) { var e = ""; s--; var d = n.internal.calculateFontSpace("3", s + "px", r).height, p = t.multiline ? u - s : (u - d) / 2; p += c; var g = -l, m = g, w = p, y = 0, v = 0, b = 0; if (0 == s) { s = 12, e = "(...) Tj\n", e += "% Width of Text: " + n.internal.calculateFontSpace(e, "1px").width + ", FieldWidth:" + h + "\n"; break } b = n.internal.calculateFontSpace(a[0] + " ", s + "px", r).width; var x = "", k = 0; for (var _ in a) { x += a[_] + " ", x = " " == x.substr(x.length - 1) ? x.substr(0, x.length - 1) : x; var C = parseInt(_); b = n.internal.calculateFontSpace(x + " ", s + "px", r).width; var A = f(C, x, s), S = _ >= a.length - 1; if (!A || S) { if (A || S) { if (S) v = C; else if (t.multiline && (d + c) * (k + 2) + c > u) continue t } else { if (!t.multiline) continue t; if ((d + c) * (k + 2) + c > u) continue t; v = C } for (var q = "", T = y; T <= v; T++) q += a[T] + " "; switch (q = " " == q.substr(q.length - 1) ? q.substr(0, q.length - 1) : q, b = n.internal.calculateFontSpace(q, s + "px", r).width, t.Q) { case 2: g = h - b - l; break; case 1: g = (h - b) / 2; break; case 0: default: g = l } e += g + " " + w + " Td\n", e += "(" + q + ") Tj\n", e += -g + " 0 Td\n", w = -(s + c), m = g, b = 0, y = v + 1, k++, x = "" } else x += " " } break } return o.text = e, o.fontSize = s, o }, n.internal.calculateAppearanceStream = function (t) { if (t.appearanceStreamContent) return t.appearanceStreamContent; if (t.V || t.DV) { var e = "", r = t.V || t.DV, i = n.internal.calculateX(t, r); e += "/Tx BMC\nq\n/F1 " + i.fontSize + " Tf\n1 0 0 1 0 0 Tm\n", e += "BT\n", e += i.text, e += "ET\n", e += "Q\nEMC\n"; var o = new n.createFormXObject(t); o.stream = e; return o } }, n.internal.calculateCoordinates = function (t, e, r, i) { var o = {}; if (this.internal) { var a = function (t) { return t * this.internal.scaleFactor }; Array.isArray(t) ? (t[0] = n.scale(t[0]), t[1] = n.scale(t[1]), t[2] = n.scale(t[2]), t[3] = n.scale(t[3]), o.lowerLeft_X = t[0] || 0, o.lowerLeft_Y = a.call(this, this.internal.pageSize.height) - t[3] - t[1] || 0, o.upperRight_X = t[0] + t[2] || 0, o.upperRight_Y = a.call(this, this.internal.pageSize.height) - t[1] || 0) : (t = n.scale(t), e = n.scale(e), r = n.scale(r), i = n.scale(i), o.lowerLeft_X = t || 0, o.lowerLeft_Y = this.internal.pageSize.height - e || 0, o.upperRight_X = t + r || 0, o.upperRight_Y = this.internal.pageSize.height - e + i || 0) } else Array.isArray(t) ? (o.lowerLeft_X = t[0] || 0, o.lowerLeft_Y = t[1] || 0, o.upperRight_X = t[0] + t[2] || 0, o.upperRight_Y = t[1] + t[3] || 0) : (o.lowerLeft_X = t || 0, o.lowerLeft_Y = e || 0, o.upperRight_X = t + r || 0, o.upperRight_Y = e + i || 0); return [o.lowerLeft_X, o.lowerLeft_Y, o.upperRight_X, o.upperRight_Y] }, n.internal.calculateColor = function (t, e, n) { var r = new Array(3); return r.r = 0 | t, r.g = 0 | e, r.b = 0 | n, r }, n.internal.getBitPosition = function (t, e) { t = t || 0; var n = 1; return n <<= e - 1, t | n }, n.internal.setBitPosition = function (t, e, n) { t = t || 0, n = n || 1; var r = 1; if (r <<= e - 1, 1 == n) var t = t | r; else var t = t & ~r; return t },/**
* jsPDF addHTML PlugIn
* Copyright (c) 2014 Diego Casorran
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
function (t) { t.addHTML = function (t, e, n, r, i) { if ("undefined" == typeof html2canvas && "undefined" == typeof rasterizeHTML) throw new Error("You need either https\\github.com\\niklasvh\\html2canvas or https\\github.com\\cburgmer\\MS_7791.js"); "number" != typeof e && (r = e, i = n), "function" == typeof r && (i = r, r = null); var o = this.internal, a = o.scaleFactor, s = o.pageSize.width, c = o.pageSize.height; if (r = r || {}, r.onrendered = function (t) { e = parseInt(e) || 0, n = parseInt(n) || 0; var o = r.dim || {}, l = o.h || 0, u = o.w || Math.min(s, t.width / a) - e, h = "JPEG"; if (r.format && (h = r.format), t.height > c && r.pagesplit) { var f = function () { for (var r = 0; ;) { var o = document.createElement("canvas"); o.width = Math.min(s * a, t.width), o.height = Math.min(c * a, t.height - r); var l = o.getContext("2d"); l.drawImage(t, 0, r, t.width, o.height, 0, 0, o.width, o.height); var f = [o, e, r ? 0 : n, o.width / a, o.height / a, h, null, "SLOW"]; if (this.addImage.apply(this, f), r += o.height, r >= t.height) break; this.addPage() } i(u, r, null, f) }.bind(this); if ("CANVAS" === t.nodeName) { var d = new Image; d.onload = f, d.src = t.toDataURL("image/png"), t = d } else f() } else { var p = Math.random().toString(35), g = [t, e, n, u, l, h, p, "SLOW"]; this.addImage.apply(this, g), i(u, l, p, g) } }.bind(this), "undefined" != typeof html2canvas && !r.rstz) return html2canvas(t, r); if ("undefined" != typeof rasterizeHTML) { var l = "drawDocument"; return "string" == typeof t && (l = /^http/.test(t) ? "drawURL" : "drawHTML"), r.width = r.width || s * a, rasterizeHTML[l](t, void 0, r).then(function (t) { r.onrendered(t.image) }, function (t) { i(null, t) }) } return null } }(e.API),/** @preserve
* jsPDF addImage plugin
* Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/
* 2013 Chris Dowling, https://github.com/gingerchris
* 2013 Trinh Ho, https://github.com/ineedfat
* 2013 Edwin Alejandro Perez, https://github.com/eaparango
* 2013 Norah Smith, https://github.com/burnburnrocket
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 James Robb, https://github.com/jamesbrobb
*
*
*/
function (e) { var n = "addImage_", r = ["jpeg", "jpg", "png"], i = function t(e) { var n = this.internal.newObject(), r = this.internal.write, i = this.internal.putStream; if (e.n = n, r("<>"), "trns" in e && e.trns.constructor == Array) { for (var o = "", a = 0, s = e.trns.length; a < s; a++) o += e.trns[a] + " " + e.trns[a] + " "; r("/Mask [" + o + "]") } if ("smask" in e && r("..\\SMask.html " + (n + 1) + " 0 R"), r("..\\Length.html " + e.data.length + ">>"), i(e.data), r("endobj"), "smask" in e) { var c = "..\\Predictor.html " + e.p + " ..\\Colors 1 \\BitsPerComponent.html " + e.bpc + " ..\\Columns.html " + e.w, l = { w: e.w, h: e.h, cs: "DeviceGray", bpc: e.bpc, dp: c, data: e.smask }; "f" in e && (l.f = e.f), t.call(this, l) } e.cs === this.color_spaces.INDEXED && (this.internal.newObject(), r("<< /Length " + e.pal.length + ">>"), i(this.arrayBufferToBinaryString(new Uint8Array(e.pal))), r("endobj")) }, o = function () { var t = this.internal.collections[n + "images"]; for (var e in t) i.call(this, t[e]) }, a = function () { var t, e = this.internal.collections[n + "images"], r = this.internal.write; for (var i in e) t = e[i], r("..\\I.html" + t.i, t.n, "0", "R") }, s = function (t) { return t && "string" == typeof t && (t = t.toUpperCase()), t in e.image_compression ? t : e.image_compression.NONE }, c = function () { var t = this.internal.collections[n + "images"]; return t || (this.internal.collections[n + "images"] = t = {}, this.internal.events.subscribe("putResources", o), this.internal.events.subscribe("putXobjectDict", a)), t }, l = function (t) { var e = 0; return t && (e = Object.keys ? Object.keys(t).length : function (t) { var e = 0; for (var n in t) t.hasOwnProperty(n) && e++; return e }(t)), e }, u = function (t) { return "undefined" == typeof t || null === t }, h = function (t) { return "string" == typeof t && e.sHashCode(t) }, f = function (t) { return r.indexOf(t) === -1 }, d = function (t) { return "function" != typeof e["process" + t.toUpperCase()] }, p = function (e) { return "object" === ("undefined" == typeof e ? "undefined" : t(e)) && 1 === e.nodeType }, g = function (e, n, r) { if ("IMG" === e.nodeName && e.hasAttribute("src")) { var i = "" + e.getAttribute("src"); if (!r && 0 === i.indexOf("dataimage\\MS_7792.html")) return i; !n && /\.png(?:[?#].*)?$/i.test(i) && (n = "png") } if ("CANVAS" === e.nodeName) var o = e; else { var o = document.createElement("canvas"); o.width = e.clientWidth || e.width, o.height = e.clientHeight || e.height; var a = o.getContext("2d"); if (!a) throw "addImage requires canvas to be supported by browser."; if (r) { var s, c, l, u, h, f, d, p, g = Math.PI / 180; "object" === ("undefined" == typeof r ? "undefined" : t(r)) && (s = r.x, c = r.y, l = r.bg, r = r.angle), p = r * g, u = Math.abs(Math.cos(p)), h = Math.abs(Math.sin(p)), f = o.width, d = o.height, o.width = d * h + f * u, o.height = d * u + f * h, isNaN(s) && (s = o.width / 2), isNaN(c) && (c = o.height / 2), a.clearRect(0, 0, o.width, o.height), a.fillStyle = l || "white", a.fillRect(0, 0, o.width, o.height), a.save(), a.translate(s, c), a.rotate(p), a.drawImage(e, -(f / 2), -(d / 2)), a.rotate(-p), a.translate(-s, -c), a.restore() } else a.drawImage(e, 0, 0, o.width, o.height) } return o.toDataURL("png" == ("" + n).toLowerCase() ? "image/png" : "image/jpeg") }, m = function (t, e) { var n; if (e) for (var r in e) if (t === e[r].alias) { n = e[r]; break } return n }, w = function (t, e, n) { return t || e || (t = -96, e = -96), t < 0 && (t = -1 * n.w * 72 / t / this.internal.scaleFactor), e < 0 && (e = -1 * n.h * 72 / e / this.internal.scaleFactor), 0 === t && (t = e * n.w / n.h), 0 === e && (e = t * n.h / n.w), [t, e] }, y = function (t, e, n, r, i, o, a) { var s = w.call(this, n, r, i), c = this.internal.getCoordinateString, l = this.internal.getVerticalCoordinateString; n = s[0], r = s[1], a[o] = i, this.internal.write("q", c(n), "0 0", c(r), c(t), l(e + r), "cm /I" + i.i, "Do Q") }; e.color_spaces = { DEVICE_RGB: "DeviceRGB", DEVICE_GRAY: "DeviceGray", DEVICE_CMYK: "DeviceCMYK", CAL_GREY: "CalGray", CAL_RGB: "CalRGB", LAB: "Lab", ICC_BASED: "ICCBased", INDEXED: "Indexed", PATTERN: "Pattern", SEPARATION: "Separation", DEVICE_N: "DeviceN" }, e.decode = { DCT_DECODE: "DCTDecode", FLATE_DECODE: "FlateDecode", LZW_DECODE: "LZWDecode", JPX_DECODE: "JPXDecode", JBIG2_DECODE: "JBIG2Decode", ASCII85_DECODE: "ASCII85Decode", ASCII_HEX_DECODE: "ASCIIHexDecode", RUN_LENGTH_DECODE: "RunLengthDecode", CCITT_FAX_DECODE: "CCITTFaxDecode" }, e.image_compression = { NONE: "NONE", FAST: "FAST", MEDIUM: "MEDIUM", SLOW: "SLOW" }, e.sHashCode = function (t) { return Array.prototype.reduce && t.split("").reduce(function (t, e) { return t = (t << 5) - t + e.charCodeAt(0), t & t }, 0) }, e.isString = function (t) { return "string" == typeof t }, e.extractInfoFromBase64DataURI = function (t) { return /^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(t) }, e.supportsArrayBuffer = function () { return "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array }, e.isArrayBuffer = function (t) { return !!this.supportsArrayBuffer() && t instanceof ArrayBuffer }, e.isArrayBufferView = function (t) { return !!this.supportsArrayBuffer() && ("undefined" != typeof Uint32Array && (t instanceof Int8Array || t instanceof Uint8Array || "undefined" != typeof Uint8ClampedArray && t instanceof Uint8ClampedArray || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array || t instanceof Float64Array)) }, e.binaryStringToUint8Array = function (t) { for (var e = t.length, n = new Uint8Array(e), r = 0; r < e; r++) n[r] = t.charCodeAt(r); return n }, e.arrayBufferToBinaryString = function (t) { this.isArrayBuffer(t) && (t = new Uint8Array(t)); for (var e = "", n = t.byteLength, r = 0; r < n; r++) e += String.fromCharCode(t[r]); return e }, e.arrayBufferToBase64 = function (t) { for (var e, n, r, i, o, a = "", s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\\index.html", c = new Uint8Array(t), l = c.byteLength, u = l % 3, h = l - u, f = 0; f < h; f += 3) o = c[f] << 16 | c[f + 1] << 8 | c[f + 2], e = (16515072 & o) >> 18, n = (258048 & o) >> 12, r = (4032 & o) >> 6, i = 63 & o, a += s[e] + s[n] + s[r] + s[i]; return 1 == u ? (o = c[h], e = (252 & o) >> 2, n = (3 & o) << 4, a += s[e] + s[n] + "==") : 2 == u && (o = c[h] << 8 | c[h + 1], e = (64512 & o) >> 10, n = (1008 & o) >> 4, r = (15 & o) << 2, a += s[e] + s[n] + s[r] + "="), a }, e.createImageInfo = function (t, e, n, r, i, o, a, s, c, l, u, h, f) { var d = { alias: s, w: e, h: n, cs: r, bpc: i, i: a, data: t }; return o && (d.f = o), c && (d.dp = c), l && (d.trns = l), u && (d.pal = u), h && (d.smask = h), f && (d.p = f), d }, e.addImage = function (e, n, i, o, a, w, v, b, x) { if ("string" != typeof n) { var k = w; w = a, a = o, o = i, i = n, n = k } if ("object" === ("undefined" == typeof e ? "undefined" : t(e)) && !p(e) && "imageData" in e) { var _ = e; e = _.imageData, n = _.format || n, i = _.x || i || 0, o = _.y || o || 0, a = _.w || a, w = _.h || w, v = _.alias || v, b = _.compression || b, x = _.rotation || _.angle || x } if (isNaN(i) || isNaN(o)) throw console.error("jsPDF.addImage: Invalid coordinates", arguments), new Error("Invalid coordinates passed to jsPDF.addImage"); var C, A = c.call(this); if (!(C = m(e, A))) { var S; if (p(e) && (e = g(e, n, x)), u(v) && (v = h(e)), !(C = m(v, A))) { if (this.isString(e)) { var q = this.extractInfoFromBase64DataURI(e); q ? (n = q[2], e = atob(q[3])) : 137 === e.charCodeAt(0) && 80 === e.charCodeAt(1) && 78 === e.charCodeAt(2) && 71 === e.charCodeAt(3) && (n = "png") } if (n = (n || "JPEG").toLowerCase(), f(n)) throw new Error("addImage currently only supports formats " + r + ", not '" + n + "'"); if (d(n)) throw new Error("please ensure that the plugin for '" + n + "' support is added"); if (this.supportsArrayBuffer() && (e instanceof Uint8Array || (S = e, e = this.binaryStringToUint8Array(e))), C = this["process" + n.toUpperCase()](e, l(A), v, s(b), S), !C) throw new Error("An unkwown error occurred whilst processing the image") } } return y.call(this, i, o, a, w, C, C.i, A), this }; var v = function (t) { var e, n, r; if (255 === !t.charCodeAt(0) || 216 === !t.charCodeAt(1) || 255 === !t.charCodeAt(2) || 224 === !t.charCodeAt(3) || !t.charCodeAt(6) === "J".charCodeAt(0) || !t.charCodeAt(7) === "F".charCodeAt(0) || !t.charCodeAt(8) === "I".charCodeAt(0) || !t.charCodeAt(9) === "F".charCodeAt(0) || 0 === !t.charCodeAt(10)) throw new Error("getJpegSize requires a binary string jpeg file"); for (var i = 256 * t.charCodeAt(4) + t.charCodeAt(5), o = 4, a = t.length; o < a;) { if (o += i, 255 !== t.charCodeAt(o)) throw new Error("getJpegSize could not find the size of the image"); if (192 === t.charCodeAt(o + 1) || 193 === t.charCodeAt(o + 1) || 194 === t.charCodeAt(o + 1) || 195 === t.charCodeAt(o + 1) || 196 === t.charCodeAt(o + 1) || 197 === t.charCodeAt(o + 1) || 198 === t.charCodeAt(o + 1) || 199 === t.charCodeAt(o + 1)) return n = 256 * t.charCodeAt(o + 5) + t.charCodeAt(o + 6), e = 256 * t.charCodeAt(o + 7) + t.charCodeAt(o + 8), r = t.charCodeAt(o + 9), [e, n, r]; o += 2, i = 256 * t.charCodeAt(o) + t.charCodeAt(o + 1) } }, b = function (t) { var e = t[0] << 8 | t[1]; if (65496 !== e) throw new Error("Supplied data is not a JPEG"); for (var n, r, i, o, a = t.length, s = (t[4] << 8) + t[5], c = 4; c < a;) { if (c += s, n = x(t, c), s = (n[2] << 8) + n[3], (192 === n[1] || 194 === n[1]) && 255 === n[0] && s > 7) return n = x(t, c + 5), r = (n[2] << 8) + n[3], i = (n[0] << 8) + n[1], o = n[4], { width: r, height: i, numcomponents: o }; c += 2 } throw new Error("getJpegSizeFromBytes could not find the size of the image") }, x = function (t, e) { return t.subarray(e, e + 5) }; e.processJPEG = function (t, e, n, r, i) { var o, a = this.color_spaces.DEVICE_RGB, s = this.decode.DCT_DECODE, c = 8; return this.isString(t) ? (o = v(t), this.createImageInfo(t, o[0], o[1], 1 == o[3] ? this.color_spaces.DEVICE_GRAY : a, c, s, e, n)) : (this.isArrayBuffer(t) && (t = new Uint8Array(t)), this.isArrayBufferView(t) ? (o = b(t), t = i || this.arrayBufferToBinaryString(t), this.createImageInfo(t, o.width, o.height, 1 == o.numcomponents ? this.color_spaces.DEVICE_GRAY : a, c, s, e, n)) : null) }, e.processJPG = function () { return this.processJPEG.apply(this, arguments) } }(e.API),/**
* jsPDF Annotations PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
function (t) { var n = { annotations: [], f2: function (t) { return t.toFixed(2) }, notEmpty: function (t) { if ("undefined" != typeof t && "" != t) return !0 } }; return e.API.annotationPlugin = n, e.API.events.push(["addPage", function (t) { this.annotationPlugin.annotations[t.pageNumber] = [] }]), t.events.push(["putPage", function (t) { for (var e = this.annotationPlugin.annotations[t.pageNumber], r = !1, i = 0; i < e.length && !r; i++) { var o = e[i]; switch (o.type) { case "link": if (n.notEmpty(o.options.url) || n.notEmpty(o.options.pageNumber)) { r = !0; break } case "reference": case "text": case "freetext": r = !0 } } if (0 != r) { this.internal.write("/Annots ["); for (var a = this.annotationPlugin.f2, s = this.internal.scaleFactor, c = this.internal.pageSize.height, l = this.internal.getPageInfo(t.pageNumber), i = 0; i < e.length; i++) { var o = e[i]; switch (o.type) { case "reference": this.internal.write(" " + o.object.objId + " 0 R "); break; case "text": var u = this.internal.newAdditionalObject(), h = this.internal.newAdditionalObject(), f = o.title || "Note", d = "/Rect [" + a(o.bounds.x * s) + " " + a(c - (o.bounds.y + o.bounds.h) * s) + " " + a((o.bounds.x + o.bounds.w) * s) + " " + a((c - o.bounds.y) * s) + "] "; y = "<>", u.content = y; var p = u.objId + " 0 R", g = 30, d = "/Rect [" + a((o.bounds.x + g) * s) + " " + a(c - (o.bounds.y + o.bounds.h) * s) + " " + a((o.bounds.x + o.bounds.w + g) * s) + " " + a((c - o.bounds.y) * s) + "] "; y = "<>", h.content = y, this.internal.write(u.objId, "0 R", h.objId, "0 R"); break; case "freetext": var d = "/Rect [" + a(o.bounds.x * s) + " " + a((c - o.bounds.y) * s) + " " + a(o.bounds.x + o.bounds.w * s) + " " + a(c - (o.bounds.y + o.bounds.h) * s) + "] ", m = o.color || "#000000"; y = "<>", this.internal.write(y); break; case "link": if (o.options.name) { var w = this.annotations._nameMap[o.options.name]; o.options.pageNumber = w.page, o.options.top = w.y } else o.options.top || (o.options.top = 0); var d = "/Rect [" + a(o.x * s) + " " + a((c - o.y) * s) + " " + a(o.x + o.w * s) + " " + a(c - (o.y + o.h) * s) + "] ", y = ""; if (o.options.url) y = "<>"; else if (o.options.pageNumber) { var t = this.internal.getPageInfo(o.options.pageNumber); switch (y = "<>", this.internal.write(y)) } } this.internal.write("]") } }]), t.createAnnotation = function (t) { switch (t.type) { case "link": this.link(t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h, t); break; case "text": case "freetext": this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push(t) } }, t.link = function (t, e, n, r, i) { this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push({ x: t, y: e, w: n, h: r, options: i, type: "link" }) }, t.link = function (t, e, n, r, i) { this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push({ x: t, y: e, w: n, h: r, options: i, type: "link" }) }, t.textWithLink = function (t, e, n, r) { var i = this.getTextWidth(t), o = this.internal.getLineHeight(); return this.text(t, e, n), n += .2 * o, this.link(e, n - o, i, o, r), i }, t.getTextWidth = function (t) { var e = this.internal.getFontSize(), n = this.getStringUnitWidth(t) * e / this.internal.scaleFactor; return n }, t.getLineHeight = function () { return this.internal.getLineHeight() }, this }(e.API), function (t) { t.autoPrint = function () { var t; return this.internal.events.subscribe("postPutResources", function () { t = this.internal.newObject(), this.internal.write("<< /S/Named /Type/Action /N/Print >>", "endobj") }), this.internal.events.subscribe("putCatalog", function () { this.internal.write("..\\OpenAction.html " + t + " 0 R") }), this } }(e.API),/**
* jsPDF Canvas PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
function (t) { return t.events.push(["initialized", function () { this.canvas.pdf = this }]), t.canvas = { getContext: function (t) { return this.pdf.context2d._canvas = this, this.pdf.context2d }, style: {} }, Object.defineProperty(t.canvas, "width", { get: function () { return this._width }, set: function (t) { this._width = t, this.getContext("2d").pageWrapX = t + 1 } }), Object.defineProperty(t.canvas, "height", { get: function () { return this._height }, set: function (t) { this._height = t, this.getContext("2d").pageWrapY = t + 1 } }), this }(e.API),/** ====================================================================
* jsPDF Cell plugin
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
* 2013 Lee Driscoll, https://github.com/lsdriscoll
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 James Hall, james@parall.ax
* 2014 Diego Casorran, https://github.com/diegocr
*
*
* ====================================================================
*/
function (t) { var e, n, r, i, o = 3, a = 13, s = { x: void 0, y: void 0, w: void 0, h: void 0, ln: void 0 }, c = 1, l = function (t, e, n, r, i) { s = { x: t, y: e, w: n, h: r, ln: i } }, u = function () { return s }, h = { left: 0, top: 0, bottom: 0 }; t.setHeaderFunction = function (t) { i = t }, t.getTextDimensions = function (t) { e = this.internal.getFont().fontName, n = this.table_font_size || this.internal.getFontSize(), r = this.internal.getFont().fontStyle; var i, o, a = 19.049976 / 25.4; o = document.createElement("font"), o.id = "jsPDFCell"; try { o.style.fontStyle = r } catch (t) { o.style.fontWeight = r } o.style.fontName = e, o.style.fontSize = n + "pt"; try { o.textContent = t } catch (e) { o.innerText = t } return document.body.appendChild(o), i = { w: (o.offsetWidth + 1) * a, h: (o.offsetHeight + 1) * a }, document.body.removeChild(o), i }, t.cellAddPage = function () { var t = this.margins || h; this.addPage(), l(t.left, t.top, void 0, void 0), c += 1 }, t.cellInitialize = function () { s = { x: void 0, y: void 0, w: void 0, h: void 0, ln: void 0 }, c = 1 }, t.cell = function (t, e, n, r, i, s, c) { var f = u(), d = !1; if (void 0 !== f.ln) if (f.ln === s) t = f.x + f.w, e = f.y; else { var p = this.margins || h; f.y + f.h + r + a >= this.internal.pageSize.height - p.bottom && (this.cellAddPage(), d = !0, this.printHeaders && this.tableHeaderRow && this.printHeaderRow(s, !0)), e = u().y + u().h, d && (e = a + 10) } if (void 0 !== i[0]) if (this.printingHeaderRow ? this.rect(t, e, n, r, "FD") : this.rect(t, e, n, r), "right" === c) { i instanceof Array || (i = [i]); for (var g = 0; g < i.length; g++) { var m = i[g], w = this.getStringUnitWidth(m) * this.internal.getFontSize(); this.text(m, t + n - w - o, e + this.internal.getLineHeight() * (g + 1)) } } else this.text(i, t + o, e + this.internal.getLineHeight()); return l(t, e, n, r, s), this }, t.arrayMax = function (t, e) { var n, r, i, o = t[0]; for (n = 0, r = t.length; n < r; n += 1) i = t[n], e ? e(o, i) === -1 && (o = i) : i > o && (o = i); return o }, t.table = function (e, n, r, i, o) { if (!r) throw "No data for PDF table"; var a, l, u, f, d, p, g, m, w, y, v = [], b = [], x = {}, k = {}, _ = [], C = [], A = !1, S = !0, q = 12, T = h; if (T.width = this.internal.pageSize.width, o && (o.autoSize === !0 && (A = !0), o.printHeaders === !1 && (S = !1), o.fontSize && (q = o.fontSize), o.css && "undefined" != typeof o.css["font-size"] && (q = 16 * o.css["font-size"]), o.margins && (T = o.margins)), this.lnMod = 0, s = { x: void 0, y: void 0, w: void 0, h: void 0, ln: void 0 }, c = 1, this.printHeaders = S, this.margins = T, this.setFontSize(q), this.table_font_size = q, void 0 === i || null === i) v = Object.keys(r[0]); else if (i[0] && "string" != typeof i[0]) { var P = 19.049976 / 25.4; for (l = 0, u = i.length; l < u; l += 1) a = i[l], v.push(a.name), b.push(a.prompt), k[a.name] = a.width * P } else v = i; if (A) for (y = function (t) { return t[a] }, l = 0, u = v.length; l < u; l += 1) { for (a = v[l], x[a] = r.map(y), _.push(this.getTextDimensions(b[l] || a).w), p = x[a], g = 0, f = p.length; g < f; g += 1) d = p[g], _.push(this.getTextDimensions(d).w); k[a] = t.arrayMax(_), _ = [] } if (S) { var I = this.calculateLineHeight(v, k, b.length ? b : v); for (l = 0, u = v.length; l < u; l += 1) a = v[l], C.push([e, n, k[a], I, String(b.length ? b[l] : a)]); this.setTableHeaderRow(C), this.printHeaderRow(1, !1) } for (l = 0, u = r.length; l < u; l += 1) { var I; for (m = r[l], I = this.calculateLineHeight(v, k, m), g = 0, w = v.length; g < w; g += 1) a = v[g], this.cell(e, n, k[a], I, m[a], l + 2, a.align) } return this.lastCellPos = s, this.table_x = e, this.table_y = n, this }, t.calculateLineHeight = function (t, e, n) { for (var r, i = 0, a = 0; a < t.length; a++) { r = t[a], n[r] = this.splitTextToSize(String(n[r]), e[r] - o); var s = this.internal.getLineHeight() * n[r].length + o; s > i && (i = s) } return i }, t.setTableHeaderRow = function (t) { this.tableHeaderRow = t }, t.printHeaderRow = function (t, e) { if (!this.tableHeaderRow) throw "Property tableHeaderRow does not exist."; var n, r, o, s; if (this.printingHeaderRow = !0, void 0 !== i) { var u = i(this, c); l(u[0], u[1], u[2], u[3], -1) } this.setFontStyle("bold"); var h = []; for (o = 0, s = this.tableHeaderRow.length; o < s; o += 1) this.setFillColor(200, 200, 200), n = this.tableHeaderRow[o], e && (this.margins.top = a, n[1] = this.margins && this.margins.top || 0, h.push(n)), r = [].concat(n), this.cell.apply(this, r.concat(t)); h.length > 0 && this.setTableHeaderRow(h), this.setFontStyle("normal"), this.printingHeaderRow = !1 } }(e.API),/**
* jsPDF Context2D PlugIn Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License. http://opensource.org/licenses/mit-license
*/
function (t) { function e() { this._isStrokeTransparent = !1, this._strokeOpacity = 1, this.strokeStyle = "#000000", this.fillStyle = "#000000", this._isFillTransparent = !1, this._fillOpacity = 1, this.font = "12pt times", this.textBaseline = "alphabetic", this.textAlign = "start", this.lineWidth = 1, this.lineJoin = "miter", this.lineCap = "butt", this._transform = [1, 0, 0, 1, 0, 0], this.globalCompositeOperation = "normal", this.globalAlpha = 1, this._clip_path = [], this.ignoreClearRect = !1, this.copy = function (t) { this._isStrokeTransparent = t._isStrokeTransparent, this._strokeOpacity = t._strokeOpacity, this.strokeStyle = t.strokeStyle, this._isFillTransparent = t._isFillTransparent, this._fillOpacity = t._fillOpacity, this.fillStyle = t.fillStyle, this.font = t.font, this.lineWidth = t.lineWidth, this.lineJoin = t.lineJoin, this.lineCap = t.lineCap, this.textBaseline = t.textBaseline, this.textAlign = t.textAlign, this._fontSize = t._fontSize, this._transform = t._transform.slice(0), this.globalCompositeOperation = t.globalCompositeOperation, this.globalAlpha = t.globalAlpha, this._clip_path = t._clip_path.slice(0), this.ignoreClearRect = t.ignoreClearRect } } t.events.push(["initialized", function () { this.context2d.pdf = this, this.context2d.internal.pdf = this, this.context2d.ctx = new e, this.context2d.ctxStack = [], this.context2d.path = [] }]), t.context2d = { pageWrapXEnabled: !1, pageWrapYEnabled: !1, pageWrapX: 9999999, pageWrapY: 9999999, ctx: new e, f2: function (t) { return t.toFixed(2) }, fillRect: function (t, e, n, r) { if (!this._isFillTransparent()) { t = this._wrapX(t), e = this._wrapY(e); var i = this._matrix_map_rect(this.ctx._transform, { x: t, y: e, w: n, h: r }); this.pdf.rect(i.x, i.y, i.w, i.h, "f") } }, strokeRect: function (t, e, n, r) { if (!this._isStrokeTransparent()) { t = this._wrapX(t), e = this._wrapY(e); var i = this._matrix_map_rect(this.ctx._transform, { x: t, y: e, w: n, h: r }); this.pdf.rect(i.x, i.y, i.w, i.h, "s") } }, clearRect: function (t, e, n, r) { if (!this.ctx.ignoreClearRect) { t = this._wrapX(t), e = this._wrapY(e); var i = this._matrix_map_rect(this.ctx._transform, { x: t, y: e, w: n, h: r }); this.save(), this.setFillStyle("#ffffff"), this.pdf.rect(i.x, i.y, i.w, i.h, "f"), this.restore() } }, save: function () { this.ctx._fontSize = this.pdf.internal.getFontSize(); var t = new e; t.copy(this.ctx), this.ctxStack.push(this.ctx), this.ctx = t }, restore: function () { this.ctx = this.ctxStack.pop(), this.setFillStyle(this.ctx.fillStyle), this.setStrokeStyle(this.ctx.strokeStyle), this.setFont(this.ctx.font), this.pdf.setFontSize(this.ctx._fontSize), this.setLineCap(this.ctx.lineCap), this.setLineWidth(this.ctx.lineWidth), this.setLineJoin(this.ctx.lineJoin) }, rect: function (t, e, n, r) { this.moveTo(t, e), this.lineTo(t + n, e), this.lineTo(t + n, e + r), this.lineTo(t, e + r), this.lineTo(t, e), this.closePath() }, beginPath: function () { this.path = [] }, closePath: function () { this.path.push({ type: "close" }) }, _getRgba: function (t) { var e = {}; if (this.internal.rxTransparent.test(t)) e.r = 0, e.g = 0, e.b = 0, e.a = 0; else { var n = this.internal.rxRgb.exec(t); null != n ? (e.r = parseInt(n[1]), e.g = parseInt(n[2]), e.b = parseInt(n[3]), e.a = 1) : (n = this.internal.rxRgba.exec(t), null != n ? (e.r = parseInt(n[1]), e.g = parseInt(n[2]), e.b = parseInt(n[3]), e.a = parseFloat(n[4])) : (e.a = 1, "#" != t.charAt(0) && (t = o.colorNameToHex(t), t || (t = "#000000")), 4 === t.length ? (e.r = t.substring(1, 2), e.r += r, e.g = t.substring(2, 3), e.g += g, e.b = t.substring(3, 4), e.b += b) : (e.r = t.substring(1, 3), e.g = t.substring(3, 5), e.b = t.substring(5, 7)), e.r = parseInt(e.r, 16), e.g = parseInt(e.g, 16), e.b = parseInt(e.b, 16))) } return e.style = t, e }, setFillStyle: function (t) { var e, n, r, i; if (this.internal.rxTransparent.test(t)) e = 0, n = 0, r = 0, i = 0; else { var a = this.internal.rxRgb.exec(t); null != a ? (e = parseInt(a[1]), n = parseInt(a[2]), r = parseInt(a[3]), i = 1) : (a = this.internal.rxRgba.exec(t), null != a ? (e = parseInt(a[1]), n = parseInt(a[2]), r = parseInt(a[3]), i = parseFloat(a[4])) : (i = 1, "#" != t.charAt(0) && (t = o.colorNameToHex(t), t || (t = "#000000")), 4 === t.length ? (e = t.substring(1, 2), e += e, n = t.substring(2, 3), n += n, r = t.substring(3, 4), r += r) : (e = t.substring(1, 3), n = t.substring(3, 5), r = t.substring(5, 7)), e = parseInt(e, 16), n = parseInt(n, 16), r = parseInt(r, 16))) } this.ctx.fillStyle = t, this.ctx._isFillTransparent = 0 == i, this.ctx._fillOpacity = i, this.pdf.setFillColor(e, n, r, { a: i }), this.pdf.setTextColor(e, n, r, { a: i }) }, setStrokeStyle: function (t) { var e = this._getRgba(t); this.ctx.strokeStyle = e.style, this.ctx._isStrokeTransparent = 0 == e.a, this.ctx._strokeOpacity = e.a, 0 === e.a ? this.pdf.setDrawColor(255, 255, 255) : 1 === e.a ? this.pdf.setDrawColor(e.r, e.g, e.b) : this.pdf.setDrawColor(e.r, e.g, e.b) }, fillText: function (t, e, n, r) { if (!this._isFillTransparent()) { e = this._wrapX(e), n = this._wrapY(n); var i = this._matrix_map_point(this.ctx._transform, [e, n]); e = i[0], n = i[1]; var o = this._matrix_rotation(this.ctx._transform), a = 57.2958 * o; if (this.ctx._clip_path.length > 0) { var s; s = window.outIntercept ? "group" === window.outIntercept.type ? window.outIntercept.stream : window.outIntercept : this.internal.getCurrentPage(), s.push("q"); var c = this.path; this.path = this.ctx._clip_path, this.ctx._clip_path = [], this._fill(null, !0), this.ctx._clip_path = this.path, this.path = c } var l = 1; try { l = this._matrix_decompose(this._getTransform()).scale[0] } catch (t) { console.warn(t) } if (l < .01) this.pdf.text(t, e, this._getBaseline(n), null, a); else { var u = this.pdf.internal.getFontSize(); this.pdf.setFontSize(u * l), this.pdf.text(t, e, this._getBaseline(n), null, a), this.pdf.setFontSize(u) } this.ctx._clip_path.length > 0 && s.push("Q") } }, strokeText: function (t, e, n, r) { if (!this._isStrokeTransparent()) { e = this._wrapX(e), n = this._wrapY(n); var i = this._matrix_map_point(this.ctx._transform, [e, n]); e = i[0], n = i[1]; var o = this._matrix_rotation(this.ctx._transform), a = 57.2958 * o; if (this.ctx._clip_path.length > 0) { var s; s = window.outIntercept ? "group" === window.outIntercept.type ? window.outIntercept.stream : window.outIntercept : this.internal.getCurrentPage(), s.push("q"); var c = this.path; this.path = this.ctx._clip_path, this.ctx._clip_path = [], this._fill(null, !0), this.ctx._clip_path = this.path, this.path = c } var l = 1; try { l = this._matrix_decompose(this._getTransform()).scale[0] } catch (t) { console.warn(t) } if (1 === l) this.pdf.text(t, e, this._getBaseline(n), { stroke: !0 }, a); else { var u = this.pdf.internal.getFontSize(); this.pdf.setFontSize(u * l), this.pdf.text(t, e, this._getBaseline(n), { stroke: !0 }, a), this.pdf.setFontSize(u) } this.ctx._clip_path.length > 0 && s.push("Q") } }, setFont: function (t) { this.ctx.font = t; var e = /\s*(\w+)\s+(\w+)\s+(\w+)\s+([\d\.]+)(px|pt|em)\s+(.*)?/; if (h = e.exec(t), null != h) { var n = h[1], r = (h[2], h[3]), i = h[4], o = h[5], a = h[6]; i = "px" === o ? Math.floor(parseFloat(i)) : "em" === o ? Math.floor(parseFloat(i) * this.pdf.getFontSize()) : Math.floor(parseFloat(i)), this.pdf.setFontSize(i), "bold" === r || "700" === r ? this.pdf.setFontStyle("bold") : "italic" === n ? this.pdf.setFontStyle("italic") : this.pdf.setFontStyle("normal"); var s, c = a, l = c.toLowerCase().split(/\s*,\s*/); s = l.indexOf("arial") != -1 ? "Arial" : l.indexOf("verdana") != -1 ? "Verdana" : l.indexOf("helvetica") != -1 ? "Helvetica" : l.indexOf("sans-serif") != -1 ? "sans-serif" : l.indexOf("fixed") != -1 ? "Fixed" : l.indexOf("monospace") != -1 ? "Monospace" : l.indexOf("terminal") != -1 ? "Terminal" : l.indexOf("courier") != -1 ? "Courier" : l.indexOf("times") != -1 ? "Times" : l.indexOf("cursive") != -1 ? "Cursive" : l.indexOf("fantasy") != -1 ? "Fantasy" : (l.indexOf("serif") != -1, "Serif"); var u; u = "bold" === r ? "bold" : "normal", this.pdf.setFont(s, u) } else { var e = /\s*(\d+)(pt|px|em)\s+([\w "]+)\s*([\w "]+)?/, h = e.exec(t); if (null != h) { var f = h[1], c = (h[2], h[3]), u = h[4]; u || (u = "normal"), f = "em" === o ? Math.floor(parseFloat(i) * this.pdf.getFontSize()) : Math.floor(parseFloat(f)), this.pdf.setFontSize(f), this.pdf.setFont(c, u) } } }, setTextBaseline: function (t) { this.ctx.textBaseline = t }, getTextBaseline: function () { return this.ctx.textBaseline }, setTextAlign: function (t) { this.ctx.textAlign = t }, getTextAlign: function () { return this.ctx.textAlign }, setLineWidth: function (t) { this.ctx.lineWidth = t, this.pdf.setLineWidth(t) }, setLineCap: function (t) { this.ctx.lineCap = t, this.pdf.setLineCap(t) }, setLineJoin: function (t) { this.ctx.lineJoin = t, this.pdf.setLineJoin(t) }, moveTo: function (t, e) { t = this._wrapX(t), e = this._wrapY(e); var n = this._matrix_map_point(this.ctx._transform, [t, e]); t = n[0], e = n[1]; var r = { type: "mt", x: t, y: e }; this.path.push(r) }, _wrapX: function (t) { return this.pageWrapXEnabled ? t % this.pageWrapX : t }, _wrapY: function (t) { return this.pageWrapYEnabled ? (this._gotoPage(this._page(t)), (t - this.lastBreak) % this.pageWrapY) : t }, transform: function (t, e, n, r, i, o) { this.ctx._transform = [t, e, n, r, i, o] }, setTransform: function (t, e, n, r, i, o) { this.ctx._transform = [t, e, n, r, i, o] }, _getTransform: function () { return this.ctx._transform }, lastBreak: 0, pageBreaks: [], _page: function (t) { if (this.pageWrapYEnabled) { this.lastBreak = 0; for (var e = 0, n = 0, r = 0; r < this.pageBreaks.length; r++) if (t >= this.pageBreaks[r]) { e++, 0 === this.lastBreak && n++; var i = this.pageBreaks[r] - this.lastBreak; this.lastBreak = this.pageBreaks[r]; var o = Math.floor(i / this.pageWrapY); n += o } if (0 === this.lastBreak) { var o = Math.floor(t / this.pageWrapY) + 1; n += o } return n + e } return this.pdf.internal.getCurrentPageInfo().pageNumber }, _gotoPage: function (t) { }, lineTo: function (t, e) { t = this._wrapX(t), e = this._wrapY(e); var n = this._matrix_map_point(this.ctx._transform, [t, e]); t = n[0], e = n[1]; var r = { type: "lt", x: t, y: e }; this.path.push(r) }, bezierCurveTo: function (t, e, n, r, i, o) { t = this._wrapX(t), e = this._wrapY(e), n = this._wrapX(n), r = this._wrapY(r), i = this._wrapX(i), o = this._wrapY(o); var a; a = this._matrix_map_point(this.ctx._transform, [i, o]), i = a[0], o = a[1], a = this._matrix_map_point(this.ctx._transform, [t, e]), t = a[0], e = a[1], a = this._matrix_map_point(this.ctx._transform, [n, r]), n = a[0], r = a[1]; var s = { type: "bct", x1: t, y1: e, x2: n, y2: r, x: i, y: o }; this.path.push(s) }, quadraticCurveTo: function (t, e, n, r) { t = this._wrapX(t), e = this._wrapY(e), n = this._wrapX(n), r = this._wrapY(r); var i; i = this._matrix_map_point(this.ctx._transform, [n, r]), n = i[0], r = i[1], i = this._matrix_map_point(this.ctx._transform, [t, e]), t = i[0], e = i[1]; var o = { type: "qct", x1: t, y1: e, x: n, y: r }; this.path.push(o) }, arc: function (t, e, n, r, i, o) { if (t = this._wrapX(t), e = this._wrapY(e), !this._matrix_is_identity(this.ctx._transform)) { var a = this._matrix_map_point(this.ctx._transform, [t, e]); t = a[0], e = a[1]; var s = this._matrix_map_point(this.ctx._transform, [0, 0]), c = this._matrix_map_point(this.ctx._transform, [0, n]); n = Math.sqrt(Math.pow(c[0] - s[0], 2) + Math.pow(c[1] - s[1], 2)) } var l = { type: "arc", x: t, y: e, radius: n, startAngle: r, endAngle: i, anticlockwise: o }; this.path.push(l) }, drawImage: function (t, e, n, r, i, o, a, s, c) { void 0 !== o && (e = o, n = a, r = s, i = c), e = this._wrapX(e), n = this._wrapY(n); var l, u = this._matrix_map_rect(this.ctx._transform, { x: e, y: n, w: r, h: i }), h = (this._matrix_map_rect(this.ctx._transform, { x: o, y: a, w: s, h: c }), /data:image\/(\w+).*/i), f = h.exec(t); l = null != f ? f[1] : "png", this.pdf.addImage(t, l, u.x, u.y, u.w, u.h) }, _matrix_multiply: function (t, e) { var n = e[0], r = e[1], i = e[2], o = e[3], a = e[4], s = e[5], c = n * t[0] + r * t[2], l = i * t[0] + o * t[2], u = a * t[0] + s * t[2] + t[4]; return r = n * t[1] + r * t[3], o = i * t[1] + o * t[3], s = a * t[1] + s * t[3] + t[5], n = c, i = l, a = u, [n, r, i, o, a, s] }, _matrix_rotation: function (t) { return Math.atan2(t[2], t[0]) }, _matrix_decompose: function (t) { var e = t[0], n = t[1], r = t[2], i = t[3], o = Math.sqrt(e * e + n * n); e /= o, n /= o; var a = e * r + n * i; r -= e * a, i -= n * a; var s = Math.sqrt(r * r + i * i); return r /= s, i /= s, a /= s, e * i < n * r && (e = -e, n = -n, a = -a, o = -o), { scale: [o, 0, 0, s, 0, 0], translate: [1, 0, 0, 1, t[4], t[5]], rotate: [e, n, -n, e, 0, 0], skew: [1, 0, a, 1, 0, 0] } }, _matrix_map_point: function (t, e) { var n = t[0], r = t[1], i = t[2], o = t[3], a = t[4], s = t[5], c = e[0], l = e[1], u = c * n + l * i + a, h = c * r + l * o + s; return [u, h] }, _matrix_map_point_obj: function (t, e) { var n = this._matrix_map_point(t, [e.x, e.y]); return { x: n[0], y: n[1] } }, _matrix_map_rect: function (t, e) { var n = this._matrix_map_point(t, [e.x, e.y]), r = this._matrix_map_point(t, [e.x + e.w, e.y + e.h]); return { x: n[0], y: n[1], w: r[0] - n[0], h: r[1] - n[1] } }, _matrix_is_identity: function (t) { return 1 == t[0] && (0 == t[1] && (0 == t[2] && (1 == t[3] && (0 == t[4] && 0 == t[5])))) }, rotate: function (t) { var e = [Math.cos(t), Math.sin(t), -Math.sin(t), Math.cos(t), 0, 0]; this.ctx._transform = this._matrix_multiply(this.ctx._transform, e) }, scale: function (t, e) { var n = [t, 0, 0, e, 0, 0]; this.ctx._transform = this._matrix_multiply(this.ctx._transform, n) }, translate: function (t, e) { var n = [1, 0, 0, 1, t, e]; this.ctx._transform = this._matrix_multiply(this.ctx._transform, n) }, stroke: function () { if (this.ctx._clip_path.length > 0) { var t; t = window.outIntercept ? "group" === window.outIntercept.type ? window.outIntercept.stream : window.outIntercept : this.internal.getCurrentPage(), t.push("q"); var e = this.path; this.path = this.ctx._clip_path, this.ctx._clip_path = [], this._stroke(!0), this.ctx._clip_path = this.path, this.path = e, this._stroke(!1), t.push("Q") } else this._stroke(!1) }, _stroke: function (t) { if (t || !this._isStrokeTransparent()) { for (var e = [], n = !1, r = this.path, i = 0; i < r.length; i++) { var o = r[i]; switch (o.type) { case "mt": e.push({ start: o, deltas: [], abs: [] }); break; case "lt": var a = [o.x - r[i - 1].x, o.y - r[i - 1].y]; e[e.length - 1].deltas.push(a), e[e.length - 1].abs.push(o); break; case "bct": var a = [o.x1 - r[i - 1].x, o.y1 - r[i - 1].y, o.x2 - r[i - 1].x, o.y2 - r[i - 1].y, o.x - r[i - 1].x, o.y - r[i - 1].y]; e[e.length - 1].deltas.push(a); break; case "qct": var s = r[i - 1].x + 2 / 3 * (o.x1 - r[i - 1].x), c = r[i - 1].y + 2 / 3 * (o.y1 - r[i - 1].y), l = o.x + 2 / 3 * (o.x1 - o.x), u = o.y + 2 / 3 * (o.y1 - o.y), h = o.x, f = o.y, a = [s - r[i - 1].x, c - r[i - 1].y, l - r[i - 1].x, u - r[i - 1].y, h - r[i - 1].x, f - r[i - 1].y]; e[e.length - 1].deltas.push(a); break; case "arc": 0 == e.length && e.push({ start: { x: 0, y: 0 }, deltas: [], abs: [] }), e[e.length - 1].arc = !0, e[e.length - 1].abs.push(o); break; case "close": n = !0 } } for (var i = 0; i < e.length; i++) { var d; if (d = i == e.length - 1 ? "s" : null, e[i].arc) for (var p = e[i].abs, g = 0; g < p.length; g++) { var m = p[g], w = 360 * m.startAngle / (2 * Math.PI), y = 360 * m.endAngle / (2 * Math.PI), v = m.x, b = m.y; this.internal.arc2(this, v, b, m.radius, w, y, m.anticlockwise, d, t) } else { var v = e[i].start.x, b = e[i].start.y; t ? (this.pdf.lines(e[i].deltas, v, b, null, null), this.pdf.clip_fixed()) : this.pdf.lines(e[i].deltas, v, b, null, d) } } } }, _isFillTransparent: function () { return this.ctx._isFillTransparent || 0 == this.globalAlpha }, _isStrokeTransparent: function () { return this.ctx._isStrokeTransparent || 0 == this.globalAlpha }, fill: function (t) { if (this.ctx._clip_path.length > 0) { var e; e = window.outIntercept ? "group" === window.outIntercept.type ? window.outIntercept.stream : window.outIntercept : this.internal.getCurrentPage(), e.push("q"); var n = this.path; this.path = this.ctx._clip_path, this.ctx._clip_path = [], this._fill(t, !0), this.ctx._clip_path = this.path, this.path = n, this._fill(t, !1), e.push("Q") } else this._fill(t, !1) }, _fill: function (t, e) { if (!this._isFillTransparent()) { var r, i = "function" == typeof this.pdf.internal.newObject2; r = window.outIntercept ? "group" === window.outIntercept.type ? window.outIntercept.stream : window.outIntercept : this.internal.getCurrentPage(); var o = [], a = window.outIntercept; if (i) switch (this.ctx.globalCompositeOperation) { case "normal": case "source-over": break; case "destination-in": case "destination-out": var s = this.pdf.internal.newStreamObject(), c = this.pdf.internal.newObject2(); c.push("<>"), c.push(">>"); var l = "MASK" + c.objId; this.pdf.internal.addGraphicsState(l, c.objId); var u = "..\\index.html" + l + " gs"; r.splice(0, 0, "q"), r.splice(1, 0, u), r.push("Q"), window.outIntercept = s; break; default: var h = "..\\index.html" + this.pdf.internal.blendModeMap[this.ctx.globalCompositeOperation.toUpperCase()]; h && this.pdf.internal.out(h + " gs") } var f = this.ctx.globalAlpha; if (this.ctx._fillOpacity < 1 && (f = this.ctx._fillOpacity), i) { var d = this.pdf.internal.newObject2(); d.push("<>"); var l = "GS_O_" + d.objId; this.pdf.internal.addGraphicsState(l, d.objId), this.pdf.internal.out("..\\index.html" + l + " gs") } for (var p = this.path, g = 0; g < p.length; g++) { var m = p[g]; switch (m.type) { case "mt": o.push({ start: m, deltas: [], abs: [] }); break; case "lt": var w = [m.x - p[g - 1].x, m.y - p[g - 1].y]; o[o.length - 1].deltas.push(w), o[o.length - 1].abs.push(m); break; case "bct": var w = [m.x1 - p[g - 1].x, m.y1 - p[g - 1].y, m.x2 - p[g - 1].x, m.y2 - p[g - 1].y, m.x - p[g - 1].x, m.y - p[g - 1].y]; o[o.length - 1].deltas.push(w); break; case "qct": var y = p[g - 1].x + 2 / 3 * (m.x1 - p[g - 1].x), v = p[g - 1].y + 2 / 3 * (m.y1 - p[g - 1].y), b = m.x + 2 / 3 * (m.x1 - m.x), x = m.y + 2 / 3 * (m.y1 - m.y), k = m.x, _ = m.y, w = [y - p[g - 1].x, v - p[g - 1].y, b - p[g - 1].x, x - p[g - 1].y, k - p[g - 1].x, _ - p[g - 1].y]; o[o.length - 1].deltas.push(w); break; case "arc": 0 === o.length && o.push({ deltas: [], abs: [] }), o[o.length - 1].arc = !0, o[o.length - 1].abs.push(m); break; case "close": o.push({ close: !0 }) } } for (var g = 0; g < o.length; g++) { var C; if (g == o.length - 1 ? (C = "f", "evenodd" === t && (C += "*")) : C = null, o[g].close) this.pdf.internal.out("h"), this.pdf.internal.out("f"); else if (o[g].arc) { o[g].start && this.internal.move2(this, o[g].start.x, o[g].start.y); for (var A = o[g].abs, S = 0; S < A.length; S++) { var q = A[S]; if ("undefined" != typeof q.startAngle) { var T = 360 * q.startAngle / (2 * Math.PI), P = 360 * q.endAngle / (2 * Math.PI), I = q.x, E = q.y; if (0 === S && this.internal.move2(this, I, E), this.internal.arc2(this, I, E, q.radius, T, P, q.anticlockwise, null, e), S === A.length - 1 && o[g].start) { var I = o[g].start.x, E = o[g].start.y; this.internal.line2(n, I, E) } } else this.internal.line2(n, q.x, q.y) } } else { var I = o[g].start.x, E = o[g].start.y; e ? (this.pdf.lines(o[g].deltas, I, E, null, null), this.pdf.clip_fixed()) : this.pdf.lines(o[g].deltas, I, E, null, C) } } window.outIntercept = a } }, pushMask: function () { var t = "function" == typeof this.pdf.internal.newObject2; if (!t) return void console.log("jsPDF v2 not enabled"); var e = this.pdf.internal.newStreamObject(), n = this.pdf.internal.newObject2(); n.push("<>"), n.push(">>"); var r = "MASK" + n.objId; this.pdf.internal.addGraphicsState(r, n.objId); var i = "..\\index.html" + r + " gs"; this.pdf.internal.out(i) }, clip: function () { if (this.ctx._clip_path.length > 0) for (var t = 0; t < this.path.length; t++) this.ctx._clip_path.push(this.path[t]); else this.ctx._clip_path = this.path; this.path = [] }, measureText: function (t) { var e = this.pdf; return { getWidth: function () { var n = e.internal.getFontSize(), r = e.getStringUnitWidth(t) * n / e.internal.scaleFactor; return r *= 1.3333 }, get width() { return this.getWidth(t) } } }, _getBaseline: function (t) { var e = parseInt(this.pdf.internal.getFontSize()), n = .25 * e; switch (this.ctx.textBaseline) { case "bottom": return t - n; case "top": return t + e; case "hanging": return t + e - n; case "middle": return t + e / 2 - n; case "ideographic": return t; case "alphabetic": default: return t } } }; var n = t.context2d; return Object.defineProperty(n, "fillStyle", { set: function (t) { this.setFillStyle(t) }, get: function () { return this.ctx.fillStyle } }), Object.defineProperty(n, "strokeStyle", { set: function (t) { this.setStrokeStyle(t) }, get: function () { return this.ctx.strokeStyle } }), Object.defineProperty(n, "lineWidth", { set: function (t) { this.setLineWidth(t) }, get: function () { return this.ctx.lineWidth } }), Object.defineProperty(n, "lineCap", { set: function (t) { this.setLineCap(t) }, get: function () { return this.ctx.lineCap } }), Object.defineProperty(n, "lineJoin", { set: function (t) { this.setLineJoin(t) }, get: function () { return this.ctx.lineJoin } }), Object.defineProperty(n, "miterLimit", { set: function (t) { this.ctx.miterLimit = t }, get: function () { return this.ctx.miterLimit } }), Object.defineProperty(n, "textBaseline", { set: function (t) { this.setTextBaseline(t) }, get: function () { return this.getTextBaseline() } }), Object.defineProperty(n, "textAlign", { set: function (t) { this.setTextAlign(t) }, get: function () { return this.getTextAlign() } }), Object.defineProperty(n, "font", { set: function (t) { this.setFont(t) }, get: function () { return this.ctx.font } }), Object.defineProperty(n, "globalCompositeOperation", { set: function (t) { this.ctx.globalCompositeOperation = t }, get: function () { return this.ctx.globalCompositeOperation } }), Object.defineProperty(n, "globalAlpha", { set: function (t) { this.ctx.globalAlpha = t }, get: function () { return this.ctx.globalAlpha } }), Object.defineProperty(n, "ignoreClearRect", { set: function (t) { this.ctx.ignoreClearRect = t }, get: function () { return this.ctx.ignoreClearRect } }), n.internal = {}, n.internal.rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/, n.internal.rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/, n.internal.rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/, n.internal.arc = function (t, e, n, r, i, o, a, s) { for (var c = !0, l = this.pdf.internal.scaleFactor, u = this.pdf.internal.pageSize.height, h = this.pdf.internal.f2, f = i * (Math.PI / 180), d = o * (Math.PI / 180), p = this.createArc(r, f, d, a), g = 0; g < p.length; g++) { var m = p[g]; c && 0 === g ? this.pdf.internal.out([h((m.x1 + e) * l), h((u - (m.y1 + n)) * l), "m", h((m.x2 + e) * l), h((u - (m.y2 + n)) * l), h((m.x3 + e) * l), h((u - (m.y3 + n)) * l), h((m.x4 + e) * l), h((u - (m.y4 + n)) * l), "c"].join(" ")) : this.pdf.internal.out([h((m.x2 + e) * l), h((u - (m.y2 + n)) * l), h((m.x3 + e) * l), h((u - (m.y3 + n)) * l), h((m.x4 + e) * l), h((u - (m.y4 + n)) * l), "c"].join(" ")), t._lastPoint = { x: e, y: n } } null !== s && this.pdf.internal.out(this.pdf.internal.getStyle(s)) }, n.internal.arc2 = function (t, e, n, r, i, o, a, s, c) { var l = e, u = n; c ? (this.arc(t, l, u, r, i, o, a, null), this.pdf.clip_fixed()) : this.arc(t, l, u, r, i, o, a, s) }, n.internal.move2 = function (t, e, n) { var r = this.pdf.internal.scaleFactor, i = this.pdf.internal.pageSize.height, o = this.pdf.internal.f2; this.pdf.internal.out([o(e * r), o((i - n) * r), "m"].join(" ")), t._lastPoint = { x: e, y: n } }, n.internal.line2 = function (t, e, n) { var r = this.pdf.internal.scaleFactor, i = this.pdf.internal.pageSize.height, o = this.pdf.internal.f2, a = { x: e, y: n }; this.pdf.internal.out([o(a.x * r), o((i - a.y) * r), "l"].join(" ")), t._lastPoint = a }, n.internal.createArc = function (t, e, n, r) { var i = 1e-5, o = 2 * Math.PI, a = Math.PI / 2, s = e; for ((s < o || s > o) && (s %= o), s < 0 && (s = o + s) ; e > n;) e -= o; var c = Math.abs(n - e); c < o && r && (c = o - c); for (var l = [], u = r ? -1 : 1, h = s; c > i;) { var f = u * Math.min(c, a), d = h + f; l.push(this.createSmallArc(t, h, d)), c -= Math.abs(d - h), h = d } return l }, n.internal.getCurrentPage = function () { return this.pdf.internal.pages[this.pdf.internal.getCurrentPageInfo().pageNumber] }, n.internal.createSmallArc = function (t, e, n) { var r = (n - e) / 2, i = t * Math.cos(r), o = t * Math.sin(r), a = i, s = -o, c = a * a + s * s, l = c + a * i + s * o, u = 4 / 3 * (Math.sqrt(2 * c * l) - l) / (a * o - s * i), h = a - u * s, f = s + u * a, d = h, p = -f, g = r + e, m = Math.cos(g), w = Math.sin(g); return { x1: t * Math.cos(e), y1: t * Math.sin(e), x2: h * m - f * w, y2: h * w + f * m, x3: d * m - p * w, y3: d * w + p * m, x4: t * Math.cos(n), y4: t * Math.sin(n) } }, this }(e.API),/** @preserve
* jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 Daniel Husar, https://github.com/danielhusar
* 2014 Wolfgang Gassler, https://github.com/woolfg
* 2014 Steven Spungin, https://github.com/flamenco
*
*
* ====================================================================
*/
function (e) { var n, r, i, a, s, c, l, u, h, f, d, p, g, m, w, y, v, b, x, k; n = function () { function t() { } return function (e) { return t.prototype = e, new t } }(), f = function (t) { var e, n, r, i, o, a, s; for (n = 0, r = t.length, e = void 0, i = !1, a = !1; !i && n !== r;) e = t[n] = t[n].trimLeft(), e && (i = !0), n++; for (n = r - 1; r && !a && n !== -1;) e = t[n] = t[n].trimRight(), e && (a = !0), n--; for (o = /\s+$/g, s = !0, n = 0; n !== r;) "\u2028" != t[n] && (e = t[n].replace(/\s+/g, " "), s && (e = e.trimLeft()), e && (s = o.test(e)), t[n] = e), n++; return t }, d = function (t, e, n, r) { return this.pdf = t, this.x = e, this.y = n, this.settings = r, this.watchFunctions = [], this.init(), this }, p = function (t) { var e, n, r; for (e = void 0, r = t.split(","), n = r.shift() ; !e && n;) e = i[n.trim().toLowerCase()], n = r.shift(); return e }, g = function (t) { t = "auto" === t ? "0px" : t, t.indexOf("em") > -1 && !isNaN(Number(t.replace("em", ""))) && (t = 18.719 * Number(t.replace("em", "")) + "px"), t.indexOf("pt") > -1 && !isNaN(Number(t.replace("pt", ""))) && (t = 1.333 * Number(t.replace("pt", "")) + "px"); var e, n, r; return n = void 0, e = 16, (r = m[t]) ? r : (r = { "xx-small": 9, "x-small": 11, small: 13, medium: 16, large: 19, "x-large": 23, "xx-large": 28, auto: 0 }[{ css_line_height_string: t }], r !== n ? m[t] = r / e : (r = parseFloat(t)) ? m[t] = r / e : (r = t.match(/([\d\.]+)(px)/), 3 === r.length ? m[t] = parseFloat(r[1]) / e : m[t] = 1)) }, h = function (t) { var e, n, r; return r = function (t) { var e; return e = function (t) { return document.defaultView && document.defaultView.getComputedStyle ? document.defaultView.getComputedStyle(t, null) : t.currentStyle ? t.currentStyle : t.style }(t), function (t) { return t = t.replace(/-\D/g, function (t) { return t.charAt(1).toUpperCase() }), e[t] } }(t), e = {}, n = void 0, e["font-family"] = p(r("font-family")) || "times", e["font-style"] = a[r("font-style")] || "normal", e["text-align"] = s[r("text-align")] || "left", n = c[r("font-weight")] || "normal", "bold" === n && ("normal" === e["font-style"] ? e["font-style"] = n : e["font-style"] = n + e["font-style"]), e["font-size"] = g(r("font-size")) || 1, e["line-height"] = g(r("line-height")) || 1, e.display = "inline" === r("display") ? "inline" : "block", n = "block" === e.display, e["margin-top"] = n && g(r("margin-top")) || 0, e["margin-bottom"] = n && g(r("margin-bottom")) || 0, e["padding-top"] = n && g(r("padding-top")) || 0, e["padding-bottom"] = n && g(r("padding-bottom")) || 0, e["margin-left"] = n && g(r("margin-left")) || 0, e["margin-right"] = n && g(r("margin-right")) || 0, e["padding-left"] = n && g(r("padding-left")) || 0, e["padding-right"] = n && g(r("padding-right")) || 0, e["page-break-before"] = r("page-break-before") || "auto", e.float = l[r("cssFloat")] || "none", e.clear = u[r("clear")] || "none", e.color = r("color"), e }, w = function (t, e, n) { var r, i, o, a, s; if (o = !1, i = void 0, a = void 0, s = void 0, r = n["#" + t.id]) if ("function" == typeof r) o = r(t, e); else for (i = 0, a = r.length; !o && i !== a;) o = r[i](t, e), i++; if (r = n[t.nodeName], !o && r) if ("function" == typeof r) o = r(t, e); else for (i = 0, a = r.length; !o && i !== a;) o = r[i](t, e), i++; return o }, k = function (t, e) { var n, r, i, o, a, s, c, l, u, h; for (n = [], r = [], i = 0, h = t.rows[0].cells.length, l = t.clientWidth; i < h;) u = t.rows[0].cells[i], r[i] = { name: u.textContent.toLowerCase().replace(/\s+/g, ""), prompt: u.textContent.replace(/\r?\n/g, ""), width: u.clientWidth / l * e.pdf.internal.pageSize.width }, i++; for (i = 1; i < t.rows.length;) { for (s = t.rows[i], a = {}, o = 0; o < s.cells.length;) a[r[o].name] = s.cells[o].textContent.replace(/\r?\n/g, ""), o++; n.push(a), i++ } return c = { rows: n, headers: r } }; var _ = { SCRIPT: 1, STYLE: 1, NOSCRIPT: 1, OBJECT: 1, EMBED: 1, SELECT: 1 }, C = 1; r = function (e, i, o) { var a, s, c, l, u, f, d, p, g; for (s = e.childNodes, a = void 0, c = h(e), u = "block" === c.display, u && (i.setBlockBoundary(), i.setBlockStyle(c)), d = 19.049976 / 25.4, l = 0, f = s.length; l < f;) { if (a = s[l], "object" === ("undefined" == typeof a ? "undefined" : t(a))) { if (i.executeWatchFunctions(a), 1 === a.nodeType && "HEADER" === a.nodeName) { var m = a, v = i.pdf.margins_doc.top; i.pdf.internal.events.subscribe("addPage", function (t) { i.y = v, r(m, i, o), i.pdf.margins_doc.top = i.y + 10, i.y += 10 }, !1) } if (8 === a.nodeType && "#comment" === a.nodeName) ~a.textContent.indexOf("ADD_PAGE") && (i.pdf.addPage(), i.y = i.pdf.margins_doc.top); else if (1 !== a.nodeType || _[a.nodeName]) if (3 === a.nodeType) { var b = a.nodeValue; if (a.nodeValue && "LI" === a.parentNode.nodeName) if ("OL" === a.parentNode.parentNode.nodeName) b = C++ + ". " + b; else { var x = c["font-size"], A = (3 - .75 * x) * i.pdf.internal.scaleFactor, S = .75 * x * i.pdf.internal.scaleFactor, q = 1.74 * x / i.pdf.internal.scaleFactor; g = function (t, e) { this.pdf.circle(t + A, e + S, q, "FD") } } 16 & a.ownerDocument.body.compareDocumentPosition(a) && i.addText(b, c) } else "string" == typeof a && i.addText(a, c); else { var T; if ("IMG" === a.nodeName) { var P = a.getAttribute("src"); T = y[i.pdf.sHashCode(P) || P] } if (T) { i.pdf.internal.pageSize.height - i.pdf.margins_doc.bottom < i.y + a.height && i.y > i.pdf.margins_doc.top && (i.pdf.addPage(), i.y = i.pdf.margins_doc.top, i.executeWatchFunctions(a)); var I = h(a), E = i.x, O = 12 / i.pdf.internal.scaleFactor, F = (I["margin-left"] + I["padding-left"]) * O, R = (I["margin-right"] + I["padding-right"]) * O, B = (I["margin-top"] + I["padding-top"]) * O, D = (I["margin-bottom"] + I["padding-bottom"]) * O; E += void 0 !== I.float && "right" === I.float ? i.settings.width - a.width - R : F, i.pdf.addImage(T, E, i.y + B, a.width, a.height), T = void 0, "right" === I.float || "left" === I.float ? (i.watchFunctions.push(function (t, e, n, r) { return i.y >= e ? (i.x += t, i.settings.width += n, !0) : !!(r && 1 === r.nodeType && !_[r.nodeName] && i.x + r.width > i.pdf.margins_doc.left + i.pdf.margins_doc.width) && (i.x += t, i.y = e, i.settings.width += n, !0) }.bind(this, "left" === I.float ? -a.width - F - R : 0, i.y + a.height + B + D, a.width)), i.watchFunctions.push(function (t, e, n) { return !(i.y < t && e === i.pdf.internal.getNumberOfPages()) || 1 === n.nodeType && "both" === h(n).clear && (i.y = t, !0) }.bind(this, i.y + a.height, i.pdf.internal.getNumberOfPages())), i.settings.width -= a.width + F + R, "left" === I.float && (i.x += a.width + F + R)) : i.y += a.height + B + D } else if ("TABLE" === a.nodeName) p = k(a, i), i.y += 10, i.pdf.table(i.x, i.y, p.rows, p.headers, { autoSize: !1, printHeaders: o.printHeaders, margins: i.pdf.margins_doc, css: h(a) }), i.y = i.pdf.lastCellPos.y + i.pdf.lastCellPos.h + 20; else if ("OL" === a.nodeName || "UL" === a.nodeName) C = 1, w(a, i, o) || r(a, i, o), i.y += 10; else if ("LI" === a.nodeName) { var j = i.x; i.x += 20 / i.pdf.internal.scaleFactor, i.y += 3, w(a, i, o) || r(a, i, o), i.x = j } else "BR" === a.nodeName ? (i.y += c["font-size"] * i.pdf.internal.scaleFactor, i.addText("\u2028", n(c))) : w(a, i, o) || r(a, i, o) } } l++ } if (o.outY = i.y, u) return i.setBlockBoundary(g) }, y = {}, v = function (t, e, n, r) { function i() { e.pdf.internal.events.publish("imagesLoaded"), r(a) } function o(t, n, r) { if (t) { var o = new Image; a = ++l, o.crossOrigin = "", o.onerror = o.onload = function () { if (o.complete && (0 === o.src.indexOf("dataimage\\MS_7792.html") && (o.width = n || o.width || 0, o.height = r || o.height || 0), o.width + o.height)) { var a = e.pdf.sHashCode(t) || t; y[a] = y[a] || o } --l || i() }, o.src = t } } for (var a, s = t.getElementsByTagName("img"), c = s.length, l = 0; c--;) o(s[c].getAttribute("src"), s[c].width, s[c].height); return l || i() }, b = function (t, e, n) { var i = t.getElementsByTagName("footer"); if (i.length > 0) { i = i[0]; var o = e.pdf.internal.write, a = e.y; e.pdf.internal.write = function () { }, r(i, e, n); var s = Math.ceil(e.y - a) + 5; e.y = a, e.pdf.internal.write = o, e.pdf.margins_doc.bottom += s; for (var c = function (t) { var o = void 0 !== t ? t.pageNumber : 1, a = e.y; e.y = e.pdf.internal.pageSize.height - e.pdf.margins_doc.bottom, e.pdf.margins_doc.bottom -= s; for (var c = i.getElementsByTagName("span"), l = 0; l < c.length; ++l) (" " + c[l].className + " ").replace(/[\n\t]/g, " ").indexOf(" pageCounter ") > -1 && (c[l].innerHTML = o), (" " + c[l].className + " ").replace(/[\n\t]/g, " ").indexOf(" totalPages ") > -1 && (c[l].innerHTML = "###jsPDFVarTotalPages###"); r(i, e, n), e.pdf.margins_doc.bottom += s, e.y = a }, l = i.getElementsByTagName("span"), u = 0; u < l.length; ++u) (" " + l[u].className + " ").replace(/[\n\t]/g, " ").indexOf(" totalPages ") > -1 && e.pdf.internal.events.subscribe("htmlRenderingFinished", e.pdf.putTotalPages.bind(e.pdf, "###jsPDFVarTotalPages###"), !0); e.pdf.internal.events.subscribe("addPage", c, !1), c(), _.FOOTER = 1 } }, x = function (t, e, n, i, o, a) { if (!e) return !1; "string" == typeof e || e.parentNode || (e = "" + e.innerHTML), "string" == typeof e && (e = function (t) { var e, n, r, i; return r = "jsPDFhtmlText" + Date.now().toString() + (1e3 * Math.random()).toFixed(0), i = "position: absolute !important;clip: rect(1px 1px 1px 1px); /* IE6, IE7 */clip: rect(1px, 1px, 1px, 1px);padding:0 !important;border:0 !important;height: 1px !important;width: 1px !important; top:auto;left:-100px;overflow: hidden;", n = document.createElement("div"), n.style.cssText = i, n.innerHTML = '
', document.body.appendChild(n), e = window.frames[r], e.document.open(), e.document.writeln(t), e.document.close(), e.document.body }(e.replace(/<\/?script[^>]*?>/gi, ""))); var s, c = new d(t, n, i, o); return v.call(this, e, c, o.elementHandlers, function (t) { b(e, c, o.elementHandlers), r(e, c, o.elementHandlers), c.pdf.internal.events.publish("htmlRenderingFinished"), s = c.dispose(), "function" == typeof a ? a(s) : t && console.error("jsPDF Warning: rendering issues? provide a callback to fromHTML!") }), s || { x: c.x, y: c.y } }, d.prototype.init = function () { return this.paragraph = { text: [], style: [] }, this.pdf.internal.write("q") }, d.prototype.dispose = function () { return this.pdf.internal.write("Q"), { x: this.x, y: this.y, ready: !0 } }, d.prototype.executeWatchFunctions = function (t) { var e = !1, n = []; if (this.watchFunctions.length > 0) { for (var r = 0; r < this.watchFunctions.length; ++r) this.watchFunctions[r](t) === !0 ? e = !0 : n.push(this.watchFunctions[r]); this.watchFunctions = n } return e }, d.prototype.splitFragmentsIntoLines = function (t, e) { var r, i, o, a, s, c, l, u, h, f, d, p, g, m, w; for (i = 12, d = this.pdf.internal.scaleFactor, s = {}, o = void 0, f = void 0, a = void 0, c = void 0, w = void 0, h = void 0, u = void 0, l = void 0, p = [], g = [p], r = 0, m = this.settings.width; t.length;) if (c = t.shift(), w = e.shift(), c) if (o = w["font-family"], f = w["font-style"], a = s[o + f], a || (a = this.pdf.internal.getFont(o, f).metadata.Unicode, s[o + f] = a), h = { widths: a.widths, kerning: a.kerning, fontSize: w["font-size"] * i, textIndent: r }, u = this.pdf.getStringUnitWidth(c, h) * h.fontSize / d, "\u2028" == c) p = [], g.push(p); else if (r + u > m) { for (l = this.pdf.splitTextToSize(c, m, h), p.push([l.shift(), w]) ; l.length;) p = [[l.shift(), w]], g.push(p); r = this.pdf.getStringUnitWidth(p[0][0], h) * h.fontSize / d } else p.push([c, w]), r += u; if (void 0 !== w["text-align"] && ("center" === w["text-align"] || "right" === w["text-align"] || "justify" === w["text-align"])) for (var y = 0; y < g.length; ++y) { var v = this.pdf.getStringUnitWidth(g[y][0][0], h) * h.fontSize / d; y > 0 && (g[y][0][1] = n(g[y][0][1])); var b = m - v; if ("right" === w["text-align"]) g[y][0][1]["margin-left"] = b; else if ("center" === w["text-align"]) g[y][0][1]["margin-left"] = b / 2; else if ("justify" === w["text-align"]) { var x = g[y][0][0].split(" ").length - 1; g[y][0][1]["word-spacing"] = b / x, y === g.length - 1 && (g[y][0][1]["word-spacing"] = 0) } } return g }, d.prototype.RenderTextFragment = function (t, e) { var n, r, i; i = 0, n = 12, this.pdf.internal.pageSize.height - this.pdf.margins_doc.bottom < this.y + this.pdf.internal.getFontSize() && (this.pdf.internal.write("ET", "Q"), this.pdf.addPage(), this.y = this.pdf.margins_doc.top, this.pdf.internal.write("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), e.color, "Td"), i = Math.max(i, e["line-height"], e["font-size"]), this.pdf.internal.write(0, (-1 * n * i).toFixed(2), "Td")), r = this.pdf.internal.getFont(e["font-family"], e["font-style"]); var o = this.getPdfColor(e.color); o !== this.lastTextColor && (this.pdf.internal.write(o), this.lastTextColor = o), void 0 !== e["word-spacing"] && e["word-spacing"] > 0 && this.pdf.internal.write(e["word-spacing"].toFixed(2), "Tw"), this.pdf.internal.write("..\\index.html" + r.id, (n * e["font-size"]).toFixed(2), "Tf", "(" + this.pdf.internal.pdfEscape(t) + ") Tj"), void 0 !== e["word-spacing"] && this.pdf.internal.write(0, "Tw") }, d.prototype.getPdfColor = function (t) { var e, n, r, i, a = /rgb\s*\(\s*(\d+),\s*(\d+),\s*(\d+\s*)\)/, s = a.exec(t); if (null != s ? (n = parseInt(s[1]), r = parseInt(s[2]), i = parseInt(s[3])) : ("#" != t.charAt(0) && (t = o.colorNameToHex(t), t || (t = "#000000")), n = t.substring(1, 3), n = parseInt(n, 16), r = t.substring(3, 5), r = parseInt(r, 16), i = t.substring(5, 7), i = parseInt(i, 16)), "string" == typeof n && /^#[0-9A-Fa-f]{6}$/.test(n)) { var c = parseInt(n.substr(1), 16); n = c >> 16 & 255, r = c >> 8 & 255, i = 255 & c } var l = this.f3; return e = 0 === n && 0 === r && 0 === i || "undefined" == typeof r ? l(n / 255) + " g" : [l(n / 255), l(r / 255), l(i / 255), "rg"].join(" ") }, d.prototype.f3 = function (t) { return t.toFixed(3) }, d.prototype.renderParagraph = function (t) { var e, n, r, i, o, a, s, c, l, u, h, d, p, g, m; if (i = f(this.paragraph.text), g = this.paragraph.style, e = this.paragraph.blockstyle, p = this.paragraph.priorblockstyle || {}, this.paragraph = { text: [], style: [], blockstyle: {}, priorblockstyle: e }, i.join("").trim()) { c = this.splitFragmentsIntoLines(i, g), s = void 0, l = void 0, n = 12, r = n / this.pdf.internal.scaleFactor, this.priorMarginBottom = this.priorMarginBottom || 0, d = (Math.max((e["margin-top"] || 0) - this.priorMarginBottom, 0) + (e["padding-top"] || 0)) * r, h = ((e["margin-bottom"] || 0) + (e["padding-bottom"] || 0)) * r, this.priorMarginBottom = e["margin-bottom"] || 0, "always" === e["page-break-before"] && (this.pdf.addPage(), this.y = 0, d = ((e["margin-top"] || 0) + (e["padding-top"] || 0)) * r), u = this.pdf.internal.write, o = void 0, a = void 0, this.y += d, u("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); for (var w = 0; c.length;) { for (s = c.shift(), l = 0, o = 0, a = s.length; o !== a;) s[o][0].trim() && (l = Math.max(l, s[o][1]["line-height"], s[o][1]["font-size"]), m = 7 * s[o][1]["font-size"]), o++; var y = 0, v = 0; void 0 !== s[0][1]["margin-left"] && s[0][1]["margin-left"] > 0 && (v = this.pdf.internal.getCoordinateString(s[0][1]["margin-left"]), y = v - w, w = v); var b = Math.max(e["margin-left"] || 0, 0) * r; for (u(y + b, (-1 * n * l).toFixed(2), "Td"), o = 0, a = s.length; o !== a;) s[o][0] && this.RenderTextFragment(s[o][0], s[o][1]), o++; if (this.y += l * r, this.executeWatchFunctions(s[0][1]) && c.length > 0) { var x = [], k = []; c.forEach(function (t) { for (var e = 0, n = t.length; e !== n;) t[e][0] && (x.push(t[e][0] + " "), k.push(t[e][1])), ++e }), c = this.splitFragmentsIntoLines(f(x), k), u("ET", "Q"), u("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td") } } return t && "function" == typeof t && t.call(this, this.x - 9, this.y - m / 2), u("ET", "Q"), this.y += h } }, d.prototype.setBlockBoundary = function (t) { return this.renderParagraph(t) }, d.prototype.setBlockStyle = function (t) { return this.paragraph.blockstyle = t }, d.prototype.addText = function (t, e) { return this.paragraph.text.push(t), this.paragraph.style.push(e) }, i = { helvetica: "helvetica", "sans-serif": "helvetica", "times new roman": "times", serif: "times", times: "times", monospace: "courier", courier: "courier" }, c = { 100: "normal", 200: "normal", 300: "normal", 400: "normal", 500: "bold", 600: "bold", 700: "bold", 800: "bold", 900: "bold", normal: "normal", bold: "bold", bolder: "bold", lighter: "normal" }, a = { normal: "normal", italic: "italic", oblique: "italic" }, s = { left: "left", right: "right", center: "center", justify: "justify" }, l = { none: "none", right: "right", left: "left" }, u = { none: "none", both: "both" }, m = { normal: 1 }, e.fromHTML = function (t, e, n, r, i, o) { return this.margins_doc = o || { top: 0, bottom: 0 }, r || (r = {}), r.elementHandlers || (r.elementHandlers = {}), x(this, t, isNaN(e) ? 4 : e, isNaN(n) ? 4 : n, r, i) } }(e.API),/** ====================================================================
* jsPDF JavaScript plugin
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
*
*
* ====================================================================
*/
function (t) { var e, n, r; t.addJS = function (t) { return r = t, this.internal.events.subscribe("postPutResources", function (t) { e = this.internal.newObject(), this.internal.write("<< /Names [(EmbeddedJS) " + (e + 1) + " 0 R] >>", "endobj"), n = this.internal.newObject(), this.internal.write("<< /S /JavaScript /JS (", r, ") >>", "endobj") }), this.internal.events.subscribe("putCatalog", function () { void 0 !== e && void 0 !== n && this.internal.write("/Names <>") }), this } }(e.API),/**
* jsPDF Outline PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
function (t) { return t.events.push(["postPutResources", function () { var t = this, e = /^(\d+) 0 obj$/; if (this.outline.root.children.length > 0) for (var n = t.outline.render().split(/\r\n/), r = 0; r < n.length; r++) { var i = n[r], o = e.exec(i); if (null != o) { var a = o[1]; t.internal.newObjectDeferredBegin(a) } t.internal.write(i) } if (this.outline.createNamedDestinations) { for (var s = this.internal.pages.length, c = [], r = 0; r < s; r++) { var l = t.internal.newObject(); c.push(l); var u = t.internal.getPageInfo(r + 1); t.internal.write("<< /D[" + u.objId + " 0 R /XYZ null null null]>> endobj") } var h = t.internal.newObject(); t.internal.write("<< /Names [ "); for (var r = 0; r < c.length; r++) t.internal.write("(page_" + (r + 1) + ")" + c[r] + " 0 R"); t.internal.write(" ] >>", "endobj"); t.internal.newObject(); t.internal.write("<< /Dests " + h + " 0 R"), t.internal.write(">>", "endobj") } }]), t.events.push(["putCatalog", function () { var t = this; t.outline.root.children.length > 0 && (t.internal.write("..\\Outlines.html", this.outline.makeRef(this.outline.root)), this.outline.createNamedDestinations && t.internal.write("..\\Names.html " + namesOid + " 0 R")) }]), t.events.push(["initialized", function () { var t = this; t.outline = { createNamedDestinations: !1, root: { children: [] } }; t.outline.add = function (t, e, n) { var r = { title: e, options: n, children: [] }; return null == t && (t = this.root), t.children.push(r), r }, t.outline.render = function () { return this.ctx = {}, this.ctx.val = "", this.ctx.pdf = t, this.genIds_r(this.root), this.renderRoot(this.root), this.renderItems(this.root), this.ctx.val }, t.outline.genIds_r = function (e) { e.id = t.internal.newObjectDeferred(); for (var n = 0; n < e.children.length; n++) this.genIds_r(e.children[n]) }, t.outline.renderRoot = function (t) { this.objStart(t), this.line("..\\Type \\Outlines.html"), t.children.length > 0 && (this.line("..\\First.html " + this.makeRef(t.children[0])), this.line("..\\Last.html " + this.makeRef(t.children[t.children.length - 1]))), this.line("..\\Count.html " + this.count_r({ count: 0 }, t)), this.objEnd() }, t.outline.renderItems = function (e) { for (var n = 0; n < e.children.length; n++) { var r = e.children[n]; this.objStart(r), this.line("..\\Title.html " + this.makeString(r.title)), this.line("..\\Parent.html " + this.makeRef(e)), n > 0 && this.line("..\\Prev.html " + this.makeRef(e.children[n - 1])), n < e.children.length - 1 && this.line("..\\Next.html " + this.makeRef(e.children[n + 1])), r.children.length > 0 && (this.line("..\\First.html " + this.makeRef(r.children[0])), this.line("..\\Last.html " + this.makeRef(r.children[r.children.length - 1]))); var i = this.count = this.count_r({ count: 0 }, r); if (i > 0 && this.line("..\\Count.html " + i), r.options && r.options.pageNumber) { var o = t.internal.getPageInfo(r.options.pageNumber); this.line("/Dest [" + o.objId + " 0 R /XYZ 0 " + this.ctx.pdf.internal.pageSize.height + " 0]") } this.objEnd() } for (var n = 0; n < e.children.length; n++) { var r = e.children[n]; this.renderItems(r) } }, t.outline.line = function (t) { this.ctx.val += t + "\r\n" }, t.outline.makeRef = function (t) { return t.id + " 0 R" }, t.outline.makeString = function (e) { return "(" + t.internal.pdfEscape(e) + ")" }, t.outline.objStart = function (t) { this.ctx.val += "\r\n" + t.id + " 0 obj\r\n<<\r\n" }, t.outline.objEnd = function (t) { this.ctx.val += ">> \r\nendobj\r\n" }, t.outline.count_r = function (t, e) { for (var n = 0; n < e.children.length; n++) t.count++, this.count_r(t, e.children[n]); return t.count } }]), this }(e.API),/**@preserve
* ====================================================================
* jsPDF PNG PlugIn
* Copyright (c) 2014 James Robb, https://github.com/jamesbrobb
*
*
* ====================================================================
*/
function (t) { var e = function () { return "function" != typeof PNG || "function" != typeof c }, n = function (e) { return e !== t.image_compression.NONE && r() }, r = function () { var t = "function" == typeof a; if (!t) throw new Error("requires deflate.js for compression"); return t }, i = function (e, n, r, i) { var c = 5, u = f; switch (i) { case t.image_compression.FAST: c = 3, u = h; break; case t.image_compression.MEDIUM: c = 6, u = d; break; case t.image_compression.SLOW: c = 9, u = p } e = l(e, n, r, u); var g = new Uint8Array(o(c)), m = s(e), w = new a(c), y = w.append(e), v = w.flush(), b = g.length + y.length + v.length, x = new Uint8Array(b + 4); return x.set(g), x.set(y, g.length), x.set(v, g.length + y.length), x[b++] = m >>> 24 & 255, x[b++] = m >>> 16 & 255, x[b++] = m >>> 8 & 255, x[b++] = 255 & m, t.arrayBufferToBinaryString(x) }, o = function (t, e) { var n = 8, r = Math.LOG2E * Math.log(32768) - 8, i = r << 4 | n, o = i << 8, a = Math.min(3, (e - 1 & 255) >> 1); return o |= a << 6, o |= 0, o += 31 - o % 31, [i, 255 & o & 255] }, s = function (t, e) { for (var n, r = 1, i = 65535 & r, o = r >>> 16 & 65535, a = t.length, s = 0; a > 0;) { n = a > e ? e : a, a -= n; do i += t[s++], o += i; while (--n); i %= 65521, o %= 65521 } return (o << 16 | i) >>> 0 }, l = function (t, e, n, r) { for (var i, o, a, s = t.length / e, c = new Uint8Array(t.length + s), l = m(), u = 0; u < s; u++) { if (a = u * e, i = t.subarray(a, a + e), r) c.set(r(i, n, o), a + u); else { for (var h = 0, f = l.length, d = []; h < f; h++) d[h] = l[h](i, n, o); var p = w(d.concat()); c.set(d[p], a + u) } o = i } return c }, u = function (t, e, n) { var r = Array.apply([], t); return r.unshift(0), r }, h = function (t, e, n) { var r, i = [], o = 0, a = t.length; for (i[0] = 1; o < a; o++) r = t[o - e] || 0, i[o + 1] = t[o] - r + 256 & 255; return i }, f = function (t, e, n) { var r, i = [], o = 0, a = t.length; for (i[0] = 2; o < a; o++) r = n && n[o] || 0, i[o + 1] = t[o] - r + 256 & 255; return i }, d = function (t, e, n) { var r, i, o = [], a = 0, s = t.length; for (o[0] = 3; a < s; a++) r = t[a - e] || 0, i = n && n[a] || 0, o[a + 1] = t[a] + 256 - (r + i >>> 1) & 255; return o }, p = function (t, e, n) { var r, i, o, a, s = [], c = 0, l = t.length; for (s[0] = 4; c < l; c++) r = t[c - e] || 0, i = n && n[c] || 0, o = n && n[c - e] || 0, a = g(r, i, o), s[c + 1] = t[c] - a + 256 & 255; return s }, g = function (t, e, n) { var r = t + e - n, i = Math.abs(r - t), o = Math.abs(r - e), a = Math.abs(r - n); return i <= o && i <= a ? t : o <= a ? e : n }, m = function () { return [u, h, f, d, p] }, w = function (t) { for (var e, n, r, i = 0, o = t.length; i < o;) e = y(t[i].slice(1)), (e < n || !n) && (n = e, r = i), i++; return r }, y = function (t) { for (var e = 0, n = t.length, r = 0; e < n;) r += Math.abs(t[e++]); return r }, v = function (e) { var n; switch (e) { case t.image_compression.FAST: n = 11; break; case t.image_compression.MEDIUM: n = 13; break; case t.image_compression.SLOW: n = 14; break; default: n = 12 } return n }; t.processPNG = function (t, r, o, a, s) { var c, l, u, h, f, d, p = this.color_spaces.DEVICE_RGB, g = this.decode.FLATE_DECODE, m = 8; if (this.isArrayBuffer(t) && (t = new Uint8Array(t)), this.isArrayBufferView(t)) { if (e()) throw new Error("PNG support requires png.js and zlib.js"); if (c = new PNG(t), t = c.imgData, m = c.bits, p = c.colorSpace, h = c.colors, [4, 6].indexOf(c.colorType) !== -1) { if (8 === c.bits) for (var w, y, b = 32 == c.pixelBitlength ? new Uint32Array(c.decodePixels().buffer) : 16 == c.pixelBitlength ? new Uint16Array(c.decodePixels().buffer) : new Uint8Array(c.decodePixels().buffer), x = b.length, k = new Uint8Array(x * c.colors), _ = new Uint8Array(x), C = c.pixelBitlength - c.bits, A = 0, S = 0; A < x; A++) { for (w = b[A], y = 0; y < C;) k[S++] = w >>> y & 255, y += c.bits; _[A] = w >>> y & 255 } if (16 === c.bits) { for (var w, b = new Uint32Array(c.decodePixels().buffer), x = b.length, k = new Uint8Array(x * (32 / c.pixelBitlength) * c.colors), _ = new Uint8Array(x * (32 / c.pixelBitlength)), q = c.colors > 1, A = 0, S = 0, T = 0; A < x;) w = b[A++], k[S++] = w >>> 0 & 255, q && (k[S++] = w >>> 16 & 255, w = b[A++], k[S++] = w >>> 0 & 255), _[T++] = w >>> 16 & 255; m = 8 } n(a) ? (t = i(k, c.width * c.colors, c.colors, a), d = i(_, c.width, 1, a)) : (t = k, d = _, g = null) } if (3 === c.colorType && (p = this.color_spaces.INDEXED, f = c.palette, c.transparency.indexed)) { for (var P = c.transparency.indexed, I = 0, A = 0, x = P.length; A < x; ++A) I += P[A]; if (I /= 255, I === x - 1 && P.indexOf(0) !== -1) u = [P.indexOf(0)]; else if (I !== x) { for (var b = c.decodePixels(), _ = new Uint8Array(b.length), A = 0, x = b.length; A < x; A++) _[A] = P[b[A]]; d = i(_, c.width, 1) } } var E = v(a); return l = g === this.decode.FLATE_DECODE ? "..\\Predictor.html " + E + " ..\\Colors.html " + h + " ..\\BitsPerComponent.html " + m + " ..\\Columns.html " + c.width : "..\\Colors.html " + h + " ..\\BitsPerComponent.html " + m + " ..\\Columns.html " + c.width, (this.isArrayBuffer(t) || this.isArrayBufferView(t)) && (t = this.arrayBufferToBinaryString(t)), (d && this.isArrayBuffer(d) || this.isArrayBufferView(d)) && (d = this.arrayBufferToBinaryString(d)), this.createImageInfo(t, c.width, c.height, p, m, g, r, o, l, u, f, d, E) } throw new Error("Unsupported PNG image data, try using JPEG instead.") } }(e.API), function (t) { t.autoPrint = function () { var t; return this.internal.events.subscribe("postPutResources", function () { t = this.internal.newObject(), this.internal.write("<< /S/Named /Type/Action /N/Print >>", "endobj") }), this.internal.events.subscribe("putCatalog", function () { this.internal.write("..\\OpenAction.html " + t + " 0 R") }), this } }(e.API),/** @preserve
* jsPDF split_text_to_size plugin - MIT license.
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* 2014 Diego Casorran, https://github.com/diegocr
*/
function (t) { var e = t.getCharWidthsArray = function (t, e) { e || (e = {}); var n, r, i, o = e.widths ? e.widths : this.internal.getFont().metadata.Unicode.widths, a = o.fof ? o.fof : 1, s = e.kerning ? e.kerning : this.internal.getFont().metadata.Unicode.kerning, c = s.fof ? s.fof : 1, l = 0, u = o[0] || a, h = []; for (n = 0, r = t.length; n < r; n++) i = t.charCodeAt(n), h.push((o[i] || u) / a + (s[i] && s[i][l] || 0) / c), l = i; return h }, n = function (t) { for (var e = t.length, n = 0; e;) e--, n += t[e]; return n }, r = t.getStringUnitWidth = function (t, r) { return n(e.call(this, t, r)) }, i = function (t, e, n, r) { for (var i = [], o = 0, a = t.length, s = 0; o !== a && s + e[o] < n;) s += e[o], o++; i.push(t.slice(0, o)); var c = o; for (s = 0; o !== a;) s + e[o] > r && (i.push(t.slice(c, o)), s = 0, c = o), s += e[o], o++; return c !== o && i.push(t.slice(c, o)), i }, o = function (t, o, a) { a || (a = {}); var s, c, l, u, h, f, d = [], p = [d], g = a.textIndent || 0, m = 0, w = 0, y = t.split(" "), v = e(" ", a)[0]; if (f = a.lineIndent === -1 ? y[0].length + 2 : a.lineIndent || 0) { var b = Array(f).join(" "), x = []; y.map(function (t) { t = t.split(/\s*\n/), t.length > 1 ? x = x.concat(t.map(function (t, e) { return (e && t.length ? "\n" : "") + t })) : x.push(t[0]) }), y = x, f = r(b, a) } for (l = 0, u = y.length; l < u; l++) { var k = 0; if (s = y[l], f && "\n" == s[0] && (s = s.substr(1), k = 1), c = e(s, a), w = n(c), g + m + w > o || k) { if (w > o) { for (h = i(s, c, o - (g + m), o), d.push(h.shift()), d = [h.pop()]; h.length;) p.push([h.shift()]); w = n(c.slice(s.length - d[0].length)) } else d = [s]; p.push(d), g = w + f, m = v } else d.push(s), g += m + w, m = v } if (f) var _ = function (t, e) { return (e ? b : "") + t.join(" ") }; else var _ = function (t) { return t.join(" ") }; return p.map(_) }; t.splitTextToSize = function (t, e, n) { n || (n = {}); var r, i = n.fontSize || this.internal.getFontSize(), a = function (t) { var e = { 0: 1 }, n = {}; if (t.widths && t.kerning) return { widths: t.widths, kerning: t.kerning }; var r = this.internal.getFont(t.fontName, t.fontStyle), i = "Unicode"; return r.metadata[i] ? { widths: r.metadata[i].widths || e, kerning: r.metadata[i].kerning || n } : { widths: e, kerning: n } }.call(this, n); r = Array.isArray(t) ? t : t.split(/\r?\n/); var s = 1 * this.internal.scaleFactor * e / i; a.textIndent = n.textIndent ? 1 * n.textIndent * this.internal.scaleFactor / i : 0, a.lineIndent = n.lineIndent; var c, l, u = []; for (c = 0, l = r.length; c < l; c++) u = u.concat(o(r[c], s, a)); return u } }(e.API),/** @preserve
jsPDF standard_fonts_metrics plugin
Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
MIT license.
*/
function (t) { var e = function (t) { for (var e = "0123456789abcdef", n = "klmnopqrstuvwxyz", r = {}, i = 0; i < n.length; i++) r[n[i]] = e[i]; var o, a, s, c, l, u = {}, h = 1, f = u, d = [], p = "", g = "", m = t.length - 1; for (i = 1; i != m;) l = t[i], i += 1, "'" == l ? a ? (c = a.join(""), a = o) : a = [] : a ? a.push(l) : "{" == l ? (d.push([f, c]), f = {}, c = o) : "}" == l ? (s = d.pop(), s[0][s[1]] = f, c = o, f = s[0]) : "-" == l ? h = -1 : c === o ? r.hasOwnProperty(l) ? (p += r[l], c = parseInt(p, 16) * h, h = 1, p = "") : p += l : r.hasOwnProperty(l) ? (g += r[l], f[c] = parseInt(g, 16) * h, h = 1, c = o, g = "") : g += l; return u }, n = { codePages: ["WinAnsiEncoding"], WinAnsiEncoding: e("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}") }, r = { Unicode: { Courier: n, "Courier-Bold": n, "Courier-BoldOblique": n, "Courier-Oblique": n, Helvetica: n, "Helvetica-Bold": n, "Helvetica-BoldOblique": n, "Helvetica-Oblique": n, "Times-Roman": n, "Times-Bold": n, "Times-BoldItalic": n, "Times-Italic": n } }, i = { Unicode: { "Courier-Oblique": e("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-BoldItalic": e("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"), "Helvetica-Bold": e("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"), Courier: e("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Courier-BoldOblique": e("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-Bold": e("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"), Helvetica: e("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"), "Helvetica-BoldOblique": e("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"), "Courier-Bold": e("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-Italic": e("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"), "Times-Roman": e("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"), "Helvetica-Oblique": e("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}") } }; t.events.push(["addFont", function (t) { var e, n, o, a = "Unicode"; e = i[a][t.PostScriptName], e && (n = t.metadata[a] ? t.metadata[a] : t.metadata[a] = {}, n.widths = e.widths, n.kerning = e.kerning), o = r[a][t.PostScriptName], o && (n = t.metadata[a] ? t.metadata[a] : t.metadata[a] = {}, n.encoding = o, o.codePages && o.codePages.length && (t.encoding = o.codePages[0])) }]) }(e.API),/** @preserve
jsPDF SVG plugin
Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
*/
function (t) { t.addSVG = function (t, e, n, r, i) { function o(t, e) { var n = e.createElement("style"); n.type = "text/css", n.styleSheet ? n.styleSheet.cssText = t : n.appendChild(e.createTextNode(t)), e.getElementsByTagName("head")[0].appendChild(n) } function a(t) { var e = "childframe", n = t.createElement("iframe"); return o(".jsPDF_sillysvg_iframe {display:none;position:absolute;}", t), n.name = e, n.setAttribute("width", 0), n.setAttribute("height", 0), n.setAttribute("frameborder", "0"), n.setAttribute("scrolling", "no"), n.setAttribute("seamless", "seamless"), n.setAttribute("class", "jsPDF_sillysvg_iframe"), t.body.appendChild(n), n } function s(t, e) { var n = (e.contentWindow || e.contentDocument).document; return n.write(t), n.close(), n.getElementsByTagName("svg")[0] } function c(t) { for (var e = parseFloat(t[1]), n = parseFloat(t[2]), r = [], i = 3, o = t.length; i < o;) "c" === t[i] ? (r.push([parseFloat(t[i + 1]), parseFloat(t[i + 2]), parseFloat(t[i + 3]), parseFloat(t[i + 4]), parseFloat(t[i + 5]), parseFloat(t[i + 6])]), i += 7) : "l" === t[i] ? (r.push([parseFloat(t[i + 1]), parseFloat(t[i + 2])]), i += 3) : i += 1; return [e, n, r] } var l; if (e === l || n === l) throw new Error("addSVG needs values for 'x' and 'y'"); var u = a(document), h = s(t, u), f = [1, 1], d = parseFloat(h.getAttribute("width")), p = parseFloat(h.getAttribute("height")); d && p && (r && i ? f = [r / d, i / p] : r ? f = [r / d, r / d] : i && (f = [i / p, i / p])); var g, m, w, y, v = h.childNodes; for (g = 0, m = v.length; g < m; g++) w = v[g], w.tagName && "PATH" === w.tagName.toUpperCase() && (y = c(w.getAttribute("d").split(" ")), y[0] = y[0] * f[0] + e, y[1] = y[1] * f[1] + n, this.lines.call(this, y[2], y[0], y[1], f)); return this } }(e.API),/** ====================================================================
* jsPDF total_pages plugin
* Copyright (c) 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
*
*
* ====================================================================
*/
function (t) { t.putTotalPages = function (t) { for (var e = new RegExp(t, "g"), n = 1; n <= this.internal.getNumberOfPages() ; n++) for (var r = 0; r < this.internal.pages[n].length; r++) this.internal.pages[n][r] = this.internal.pages[n][r].replace(e, this.internal.getNumberOfPages()); return this } }(e.API),/** ====================================================================
* jsPDF XMP metadata plugin
* Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi
*
*
* ====================================================================
*/
function (t) { var e = "", n = "", r = ""; t.addMetadata = function (t, i) { return n = i || "..\\http\\jspdf.default.namespaceuri\\MS_7793.html", e = t, this.internal.events.subscribe("postPutResources", function () { if (e) { var t = '
', i = '', o = "", a = "", s = unescape(encodeURIComponent(t)), c = unescape(encodeURIComponent(i)), l = unescape(encodeURIComponent(e)), u = unescape(encodeURIComponent(o)), h = unescape(encodeURIComponent(a)), f = c.length + l.length + u.length + s.length + h.length; r = this.internal.newObject(), this.internal.write("<< /Type /Metadata /Subtype /XML /Length " + f + " >>"), this.internal.write("stream"), this.internal.write(s + c + l + u + h), this.internal.write("endstream"), this.internal.write("endobj") } else r = "" }), this.internal.events.subscribe("putCatalog", function () { r && this.internal.write("..\\Metadata.html " + r + " 0 R") }), this } }(e.API), function (t) { if (t.URL = t.URL || t.webkitURL, t.Blob && t.URL) try { return void new Blob } catch (t) { } var e = t.BlobBuilder || t.WebKitBlobBuilder || t.MozBlobBuilder || function (t) { var e = function (t) { return Object.prototype.toString.call(t).match(/^\[object\s(.*)\]$/)[1] }, n = function () { this.data = [] }, r = function (t, e, n) { this.data = t, this.size = t.length, this.type = e, this.encoding = n }, i = n.prototype, o = r.prototype, a = t.FileReaderSync, s = function (t) { this.code = this[this.name = t] }, c = "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "), l = c.length, u = t.URL || t.webkitURL || t, h = u.createObjectURL, f = u.revokeObjectURL, d = u, p = t.btoa, g = t.atob, m = t.ArrayBuffer, w = t.Uint8Array, y = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/; for (r.fake = o.fake = !0; l--;) s.prototype[c[l]] = l + 1; return u.createObjectURL || (d = t.URL = function (t) { var e, n = document.createElementNS("..\\http\\www.w3.org\\1999\\MS_7795.html", "a"); return n.href = t, "origin" in n || ("data:" === n.protocol.toLowerCase() ? n.origin = null : (e = t.match(y), n.origin = e && e[1])), n }), d.createObjectURL = function (t) { var e, n = t.type; return null === n && (n = "application/octet-stream"), t instanceof r ? (e = "data:" + n, "base64" === t.encoding ? e + ";base64," + t.data : "URI" === t.encoding ? e + "," + decodeURIComponent(t.data) : p ? e + ";base64," + p(t.data) : e + "," + encodeURIComponent(t.data)) : h ? h.call(u, t) : void 0 }, d.revokeObjectURL = function (t) { "data:" !== t.substring(0, 5) && f && f.call(u, t) }, i.append = function (t) { var n = this.data; if (w && (t instanceof m || t instanceof w)) { for (var i = "", o = new w(t), c = 0, l = o.length; c < l; c++) i += String.fromCharCode(o[c]); n.push(i) } else if ("Blob" === e(t) || "File" === e(t)) { if (!a) throw new s("NOT_READABLE_ERR"); var u = new a; n.push(u.readAsBinaryString(t)) } else t instanceof r ? "base64" === t.encoding && g ? n.push(g(t.data)) : "URI" === t.encoding ? n.push(decodeURIComponent(t.data)) : "raw" === t.encoding && n.push(t.data) : ("string" != typeof t && (t += ""), n.push(unescape(encodeURIComponent(t)))) }, i.getBlob = function (t) { return arguments.length || (t = null), new r(this.data.join(""), t, "raw") }, i.toString = function () { return "[object BlobBuilder]" }, o.slice = function (t, e, n) { var i = arguments.length; return i < 3 && (n = null), new r(this.data.slice(t, i > 1 ? e : this.data.length), n, this.encoding) }, o.toString = function () { return "[object Blob]" }, o.close = function () { this.size = 0, delete this.data }, n }(t); t.Blob = function (t, n) { var r = n ? n.type || "" : "", i = new e; if (t) for (var o = 0, a = t.length; o < a; o++) Uint8Array && t[o] instanceof Uint8Array ? i.append(t[o].buffer) : i.append(t[o]); var s = i.getBlob(r); return !s.slice && s.webkitSlice && (s.slice = s.webkitSlice), s }; var n = Object.getPrototypeOf || function (t) { return t.__proto__ }; t.Blob.prototype = n(new t.Blob) }("undefined" != typeof self && self || "undefined" != typeof window && window || (void 0).content || void 0); var i = i || function (t) { if ("undefined" == typeof navigator || !/MSIE [1-9]\./.test(navigator.userAgent)) { var e = t.document, n = function () { return t.URL || t.webkitURL || t }, r = e.createElementNS("..\\http\\www.w3.org\\1999\\MS_7795.html", "a"), i = "download" in r, o = function (t) { var e = new MouseEvent("click"); t.dispatchEvent(e) }, a = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent), s = t.webkitRequestFileSystem, c = t.requestFileSystem || s || t.mozRequestFileSystem, l = function (e) { (t.setImmediate || t.setTimeout)(function () { throw e }, 0) }, u = "application/octet-stream", h = 0, f = 500, d = function (e) { var r = function () { "string" == typeof e ? n().revokeObjectURL(e) : e.remove() }; t.chrome ? r() : setTimeout(r, f) }, p = function (t, e, n) { e = [].concat(e); for (var r = e.length; r--;) { var i = t["on" + e[r]]; if ("function" == typeof i) try { i.call(t, n || t) } catch (t) { l(t) } } }, g = function (t) { return /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type) ? new Blob(["\ufeff", t], { type: t.type }) : t }, m = function (e, l, f) { f || (e = g(e)); var m, w, y, v = this, b = e.type, x = !1, k = function () { p(v, "writestart progress write writeend".split(" ")) }, _ = function () { if (w && a && "undefined" != typeof FileReader) { var r = new FileReader; return r.onloadend = function () { var t = r.result; w.location.href = "data:attachment/file" + t.slice(t.search(/[,;]/)), v.readyState = v.DONE, k() }, r.readAsDataURL(e), void (v.readyState = v.INIT) } if (!x && m || (m = n().createObjectURL(e)), w) w.location.href = m; else { var i = t.open(m, "_blank"); void 0 == i && a && (t.location.href = m) } v.readyState = v.DONE, k(), d(m) }, C = function (t) { return function () { if (v.readyState !== v.DONE) return t.apply(this, arguments) } }, A = { create: !0, exclusive: !1 }; return v.readyState = v.INIT, l || (l = "download"), i ? (m = n().createObjectURL(e), void setTimeout(function () { r.href = m, r.download = l, o(r), k(), d(m), v.readyState = v.DONE })) : (t.chrome && b && b !== u && (y = e.slice || e.webkitSlice, e = y.call(e, 0, e.size, u), x = !0), s && "download" !== l && (l += ".download"), (b === u || s) && (w = t), c ? (h += e.size, void c(t.TEMPORARY, h, C(function (t) { t.root.getDirectory("saved", A, C(function (t) { var n = function () { t.getFile(l, A, C(function (t) { t.createWriter(C(function (n) { n.onwriteend = function (e) { w.location.href = t.toURL(), v.readyState = v.DONE, p(v, "writeend", e), d(t) }, n.onerror = function () { var t = n.error; t.code !== t.ABORT_ERR && _() }, "writestart progress write abort".split(" ").forEach(function (t) { n["on" + t] = v["on" + t] }), n.write(e), v.abort = function () { n.abort(), v.readyState = v.DONE }, v.readyState = v.WRITING }), _) }), _) }; t.getFile(l, { create: !1 }, C(function (t) { t.remove(), n() }), C(function (t) { t.code === t.NOT_FOUND_ERR ? n() : _() })) }), _) }), _)) : void _()) }, w = m.prototype, y = function (t, e, n) { return new m(t, e, n) }; return "undefined" != typeof navigator && navigator.msSaveOrOpenBlob ? function (t, e, n) { return n || (t = g(t)), navigator.msSaveOrOpenBlob(t, e || "download") } : (w.abort = function () { var t = this; t.readyState = t.DONE, p(t, "abort") }, w.readyState = w.INIT = 0, w.WRITING = 1, w.DONE = 2, w.error = w.onwritestart = w.onprogress = w.onwrite = w.onabort = w.onerror = w.onwriteend = null, y) } }("undefined" != typeof self && self || "undefined" != typeof window && window || (void 0).content); "undefined" != typeof module && module.exports ? module.exports.saveAs = i : "undefined" != typeof define && null !== define && null != define.amd && define([], function () { return i }),/*
* Copyright (c) 2012 chick307
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
void function (t, e) { "object" == typeof module ? module.exports = e() : "function" == typeof define ? define(e) : t.adler32cs = e() }(e, function () { var t = "function" == typeof ArrayBuffer && "function" == typeof Uint8Array, e = null, n = function () { if (!t) return function () { return !1 }; try { var n = {}; "function" == typeof n.Buffer && (e = n.Buffer) } catch (t) { } return function (t) { return t instanceof ArrayBuffer || null !== e && t instanceof e } }(), r = function () { return null !== e ? function (t) { return new e(t, "utf8").toString("binary") } : function (t) { return unescape(encodeURIComponent(t)) } }(), i = 65521, o = function (t, e) { for (var n = 65535 & t, r = t >>> 16, o = 0, a = e.length; o < a; o++) n = (n + (255 & e.charCodeAt(o))) % i, r = (r + n) % i; return (r << 16 | n) >>> 0 }, a = function (t, e) { for (var n = 65535 & t, r = t >>> 16, o = 0, a = e.length; o < a; o++) n = (n + e[o]) % i, r = (r + n) % i; return (r << 16 | n) >>> 0 }, s = {}, c = s.Adler32 = function () { var e = function (t) { if (!(this instanceof e)) throw new TypeError("Constructor cannot called be as a function."); if (!isFinite(t = null == t ? 1 : +t)) throw new Error("First arguments needs to be a finite number."); this.checksum = t >>> 0 }, i = e.prototype = {}; return i.constructor = e, e.from = function (t) { return t.prototype = i, t }(function (t) { if (!(this instanceof e)) throw new TypeError("Constructor cannot called be as a function."); if (null == t) throw new Error("First argument needs to be a string."); this.checksum = o(1, t.toString()) }), e.fromUtf8 = function (t) { return t.prototype = i, t }(function (t) { if (!(this instanceof e)) throw new TypeError("Constructor cannot called be as a function."); if (null == t) throw new Error("First argument needs to be a string."); var n = r(t.toString()); this.checksum = o(1, n) }), t && (e.fromBuffer = function (t) { return t.prototype = i, t }(function (t) { if (!(this instanceof e)) throw new TypeError("Constructor cannot called be as a function."); if (!n(t)) throw new Error("First argument needs to be ArrayBuffer."); var r = new Uint8Array(t); return this.checksum = a(1, r) })), i.update = function (t) { if (null == t) throw new Error("First argument needs to be a string."); return t = t.toString(), this.checksum = o(this.checksum, t) }, i.updateUtf8 = function (t) { if (null == t) throw new Error("First argument needs to be a string."); var e = r(t.toString()); return this.checksum = o(this.checksum, e) }, t && (i.updateBuffer = function (t) { if (!n(t)) throw new Error("First argument needs to be ArrayBuffer."); var e = new Uint8Array(t); return this.checksum = a(this.checksum, e) }), i.clone = function () { return new c(this.checksum) }, e }(); return s.from = function (t) { if (null == t) throw new Error("First argument needs to be a string."); return o(1, t.toString()) }, s.fromUtf8 = function (t) { if (null == t) throw new Error("First argument needs to be a string."); var e = r(t.toString()); return o(1, e) }, t && (s.fromBuffer = function (t) { if (!n(t)) throw new Error("First argument need to be ArrayBuffer."); var e = new Uint8Array(t); return a(1, e) }), s });/**
* CssColors
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
var o = {}; o._colorsTable = { aliceblue: "#f0f8ff", antiquewhite: "#faebd7", aqua: "#00ffff", aquamarine: "#7fffd4", azure: "#f0ffff", beige: "#f5f5dc", bisque: "#ffe4c4", black: "#000000", blanchedalmond: "#ffebcd", blue: "#0000ff", blueviolet: "#8a2be2", brown: "#a52a2a", burlywood: "#deb887", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", cornflowerblue: "#6495ed", cornsilk: "#fff8dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkgray: "#a9a9a9", darkgreen: "#006400", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkseagreen: "#8fbc8f", darkslateblue: "#483d8b", darkslategray: "#2f4f4f", darkturquoise: "#00ced1", darkviolet: "#9400d3", deeppink: "#ff1493", deepskyblue: "#00bfff", dimgray: "#696969", dodgerblue: "#1e90ff", firebrick: "#b22222", floralwhite: "#fffaf0", forestgreen: "#228b22", fuchsia: "#ff00ff", gainsboro: "#dcdcdc", ghostwhite: "#f8f8ff", gold: "#ffd700", goldenrod: "#daa520", gray: "#808080", green: "#008000", greenyellow: "#adff2f", honeydew: "#f0fff0", hotpink: "#ff69b4", "indianred ": "#cd5c5c", indigo: "#4b0082", ivory: "#fffff0", khaki: "#f0e68c", lavender: "#e6e6fa", lavenderblush: "#fff0f5", lawngreen: "#7cfc00", lemonchiffon: "#fffacd", lightblue: "#add8e6", lightcoral: "#f08080", lightcyan: "#e0ffff", lightgoldenrodyellow: "#fafad2", lightgrey: "#d3d3d3", lightgreen: "#90ee90", lightpink: "#ffb6c1", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", lightskyblue: "#87cefa", lightslategray: "#778899", lightsteelblue: "#b0c4de", lightyellow: "#ffffe0", lime: "#00ff00", limegreen: "#32cd32", linen: "#faf0e6", magenta: "#ff00ff", maroon: "#800000", mediumaquamarine: "#66cdaa", mediumblue: "#0000cd", mediumorchid: "#ba55d3", mediumpurple: "#9370d8", mediumseagreen: "#3cb371", mediumslateblue: "#7b68ee", mediumspringgreen: "#00fa9a", mediumturquoise: "#48d1cc", mediumvioletred: "#c71585", midnightblue: "#191970", mintcream: "#f5fffa", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", navajowhite: "#ffdead", navy: "#000080", oldlace: "#fdf5e6", olive: "#808000", olivedrab: "#6b8e23", orange: "#ffa500", orangered: "#ff4500", orchid: "#da70d6", palegoldenrod: "#eee8aa", palegreen: "#98fb98", paleturquoise: "#afeeee", palevioletred: "#d87093", papayawhip: "#ffefd5", peachpuff: "#ffdab9", peru: "#cd853f", pink: "#ffc0cb", plum: "#dda0dd", powderblue: "#b0e0e6", purple: "#800080", red: "#ff0000", rosybrown: "#bc8f8f", royalblue: "#4169e1", saddlebrown: "#8b4513", salmon: "#fa8072", sandybrown: "#f4a460", seagreen: "#2e8b57", seashell: "#fff5ee", sienna: "#a0522d", silver: "#c0c0c0", skyblue: "#87ceeb", slateblue: "#6a5acd", slategray: "#708090", snow: "#fffafa", springgreen: "#00ff7f", steelblue: "#4682b4", tan: "#d2b48c", teal: "#008080", thistle: "#d8bfd8", tomato: "#ff6347", turquoise: "#40e0d0", violet: "#ee82ee", wheat: "#f5deb3", white: "#ffffff", whitesmoke: "#f5f5f5", yellow: "#ffff00", yellowgreen: "#9acd32" }, o.colorNameToHex = function (t) { return t = t.toLowerCase(), "undefined" != typeof this._colorsTable[t] && this._colorsTable[t] };/*
Deflate.js - https://github.com/gildas-lormeau/zip.js
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var a = function (t) { function e() { function t(t) { var e, n, i, o, a, c, l = r.dyn_tree, u = r.stat_desc.static_tree, h = r.stat_desc.extra_bits, f = r.stat_desc.extra_base, p = r.stat_desc.max_length, g = 0; for (o = 0; o <= s; o++) t.bl_count[o] = 0; for (l[2 * t.heap[t.heap_max] + 1] = 0, e = t.heap_max + 1; e < d; e++) n = t.heap[e], o = l[2 * l[2 * n + 1] + 1] + 1, o > p && (o = p, g++), l[2 * n + 1] = o, n > r.max_code || (t.bl_count[o]++, a = 0, n >= f && (a = h[n - f]), c = l[2 * n], t.opt_len += c * (o + a), u && (t.static_len += c * (u[2 * n + 1] + a))); if (0 !== g) { do { for (o = p - 1; 0 === t.bl_count[o];) o--; t.bl_count[o]--, t.bl_count[o + 1] += 2, t.bl_count[p]--, g -= 2 } while (g > 0); for (o = p; 0 !== o; o--) for (n = t.bl_count[o]; 0 !== n;) i = t.heap[--e], i > r.max_code || (l[2 * i + 1] != o && (t.opt_len += (o - l[2 * i + 1]) * l[2 * i], l[2 * i + 1] = o), n--) } } function e(t, e) { var n = 0; do n |= 1 & t, t >>>= 1, n <<= 1; while (--e > 0); return n >>> 1 } function n(t, n, r) { var i, o, a, c = [], l = 0; for (i = 1; i <= s; i++) c[i] = l = l + r[i - 1] << 1; for (o = 0; o <= n; o++) a = t[2 * o + 1], 0 !== a && (t[2 * o] = e(c[a]++, a)) } var r = this; r.build_tree = function (e) { var i, o, a, s = r.dyn_tree, c = r.stat_desc.static_tree, l = r.stat_desc.elems, u = -1; for (e.heap_len = 0, e.heap_max = d, i = 0; i < l; i++) 0 !== s[2 * i] ? (e.heap[++e.heap_len] = u = i, e.depth[i] = 0) : s[2 * i + 1] = 0; for (; e.heap_len < 2;) a = e.heap[++e.heap_len] = u < 2 ? ++u : 0, s[2 * a] = 1, e.depth[a] = 0, e.opt_len--, c && (e.static_len -= c[2 * a + 1]); for (r.max_code = u, i = Math.floor(e.heap_len / 2) ; i >= 1; i--) e.pqdownheap(s, i); a = l; do i = e.heap[1], e.heap[1] = e.heap[e.heap_len--], e.pqdownheap(s, 1), o = e.heap[1], e.heap[--e.heap_max] = i, e.heap[--e.heap_max] = o, s[2 * a] = s[2 * i] + s[2 * o], e.depth[a] = Math.max(e.depth[i], e.depth[o]) + 1, s[2 * i + 1] = s[2 * o + 1] = a, e.heap[1] = a++, e.pqdownheap(s, 1); while (e.heap_len >= 2); e.heap[--e.heap_max] = e.heap[1], t(e), n(s, r.max_code, e.bl_count) } } function n(t, e, n, r, i) { var o = this; o.static_tree = t, o.extra_bits = e, o.extra_base = n, o.elems = r, o.max_length = i } function r(t, e, n, r, i) { var o = this; o.good_length = t, o.max_lazy = e, o.nice_length = n, o.max_chain = r, o.func = i } function i(t, e, n, r) { var i = t[2 * e], o = t[2 * n]; return i < o || i == o && r[e] <= r[n] } function o() { function t() { var t; for (It = 2 * St, Ot[Rt - 1] = 0, t = 0; t < Rt - 1; t++) Ot[t] = 0; Yt = L[Gt].max_lazy, Qt = L[Gt].good_length, Kt = L[Gt].nice_length, Vt = L[Gt].max_chain, Ut = 0, zt = 0, Wt = 0, Nt = Xt = tt - 1, Mt = 0, Ft = 0 } function r() { var t; for (t = 0; t < f; t++) $t[2 * t] = 0; for (t = 0; t < c; t++) Zt[2 * t] = 0; for (t = 0; t < l; t++) te[2 * t] = 0; $t[2 * p] = 1, ee.opt_len = ee.static_len = 0, se = le = 0 } function o() { ne.dyn_tree = $t, ne.stat_desc = n.static_l_desc, re.dyn_tree = Zt, re.stat_desc = n.static_d_desc, ie.dyn_tree = te, ie.stat_desc = n.static_bl_desc, he = 0, fe = 0, ue = 8, r() } function a(t, e) { var n, r, i = -1, o = t[1], a = 0, s = 7, c = 4; for (0 === o && (s = 138, c = 3), t[2 * (e + 1) + 1] = 65535, n = 0; n <= e; n++) r = o, o = t[2 * (n + 1) + 1], ++a < s && r == o || (a < c ? te[2 * r] += a : 0 !== r ? (r != i && te[2 * r]++, te[2 * m]++) : a <= 10 ? te[2 * w]++ : te[2 * y]++, a = 0, i = r, 0 === o ? (s = 138, c = 3) : r == o ? (s = 6, c = 3) : (s = 7, c = 4)) } function s() { var t; for (a($t, ne.max_code), a(Zt, re.max_code), ie.build_tree(ee), t = l - 1; t >= 3 && 0 === te[2 * e.bl_order[t] + 1]; t--); return ee.opt_len += 3 * (t + 1) + 5 + 5 + 4, t } function u(t) { ee.pending_buf[ee.pending++] = t } function d(t) { u(255 & t), u(t >>> 8 & 255) } function g(t) { u(t >> 8 & 255), u(255 & t & 255) } function R(t, e) { var n, r = e; fe > v - r ? (n = t, he |= n << fe & 65535, d(he), he = n >>> v - fe, fe += r - v) : (he |= t << fe & 65535, fe += r) } function rt(t, e) { var n = 2 * t; R(65535 & e[n], 65535 & e[n + 1]) } function it(t, e) { var n, r, i = -1, o = t[1], a = 0, s = 7, c = 4; for (0 === o && (s = 138, c = 3), n = 0; n <= e; n++) if (r = o, o = t[2 * (n + 1) + 1], !(++a < s && r == o)) { if (a < c) { do rt(r, te); while (0 !== --a) } else 0 !== r ? (r != i && (rt(r, te), a--), rt(m, te), R(a - 3, 2)) : a <= 10 ? (rt(w, te), R(a - 3, 3)) : (rt(y, te), R(a - 11, 7)); a = 0, i = r, 0 === o ? (s = 138, c = 3) : r == o ? (s = 6, c = 3) : (s = 7, c = 4) } } function ot(t, n, r) { var i; for (R(t - 257, 5), R(n - 1, 5), R(r - 4, 4), i = 0; i < r; i++) R(te[2 * e.bl_order[i] + 1], 3); it($t, t - 1), it(Zt, n - 1) } function at() { 16 == fe ? (d(he), he = 0, fe = 0) : fe >= 8 && (u(255 & he), he >>>= 8, fe -= 8) } function st() { R($ << 1, 3), rt(p, n.static_ltree), at(), 1 + ue + 10 - fe < 9 && (R($ << 1, 3), rt(p, n.static_ltree), at()), ue = 7 } function ct(t, n) { var r, i, o; if (ee.pending_buf[ce + 2 * se] = t >>> 8 & 255, ee.pending_buf[ce + 2 * se + 1] = 255 & t, ee.pending_buf[oe + se] = 255 & n, se++, 0 === t ? $t[2 * n]++ : (le++, t--, $t[2 * (e._length_code[n] + h + 1)]++, Zt[2 * e.d_code(t)]++), 0 === (8191 & se) && Gt > 2) { for (r = 8 * se, i = Ut - zt, o = 0; o < c; o++) r += Zt[2 * o] * (5 + e.extra_dbits[o]); if (r >>>= 3, le < Math.floor(se / 2) && r < Math.floor(i / 2)) return !0 } return se == ae - 1 } function lt(t, n) { var r, i, o, a, s = 0; if (0 !== se) do r = ee.pending_buf[ce + 2 * s] << 8 & 65280 | 255 & ee.pending_buf[ce + 2 * s + 1], i = 255 & ee.pending_buf[oe + s], s++, 0 === r ? rt(i, t) : (o = e._length_code[i], rt(o + h + 1, t), a = e.extra_lbits[o], 0 !== a && (i -= e.base_length[o], R(i, a)), r--, o = e.d_code(r), rt(o, n), a = e.extra_dbits[o], 0 !== a && (r -= e.base_dist[o], R(r, a))); while (s < se); rt(p, t), ue = t[2 * p + 1] } function ut() { fe > 8 ? d(he) : fe > 0 && u(255 & he), he = 0, fe = 0 } function ht(t, e, n) { ut(), ue = 8, n && (d(e), d(~e)), ee.pending_buf.set(Pt.subarray(t, t + e), ee.pending), ee.pending += e } function ft(t, e, n) { R((K << 1) + (n ? 1 : 0), 3), ht(t, e, !0) } function dt(t, e, i) { var o, a, c = 0; Gt > 0 ? (ne.build_tree(ee), re.build_tree(ee), c = s(), o = ee.opt_len + 3 + 7 >>> 3, a = ee.static_len + 3 + 7 >>> 3, a <= o && (o = a)) : o = a = e + 5, e + 4 <= o && t != -1 ? ft(t, e, i) : a == o ? (R(($ << 1) + (i ? 1 : 0), 3), lt(n.static_ltree, n.static_dtree)) : (R((Z << 1) + (i ? 1 : 0), 3), ot(ne.max_code + 1, re.max_code + 1, c + 1), lt($t, Zt)), r(), i && ut() } function pt(t) { dt(zt >= 0 ? zt : -1, Ut - zt, t), zt = Ut, xt.flush_pending() } function gt() { var t, e, n, r; do { if (r = It - Wt - Ut, 0 === r && 0 === Ut && 0 === Wt) r = St; else if (r == -1) r--; else if (Ut >= St + St - nt) { Pt.set(Pt.subarray(St, St + St), 0), Ht -= St, Ut -= St, zt -= St, t = Rt, n = t; do e = 65535 & Ot[--n], Ot[n] = e >= St ? e - St : 0; while (0 !== --t); t = St, n = t; do e = 65535 & Et[--n], Et[n] = e >= St ? e - St : 0; while (0 !== --t); r += St } if (0 === xt.avail_in) return; t = xt.read_buf(Pt, Ut + Wt, r), Wt += t, Wt >= tt && (Ft = 255 & Pt[Ut], Ft = (Ft << jt ^ 255 & Pt[Ut + 1]) & Dt) } while (Wt < nt && 0 !== xt.avail_in) } function mt(t) { var e, n = 65535; for (n > _t - 5 && (n = _t - 5) ; ;) { if (Wt <= 1) { if (gt(), 0 === Wt && t == C) return U; if (0 === Wt) break } if (Ut += Wt, Wt = 0, e = zt + n, (0 === Ut || Ut >= e) && (Wt = Ut - e, Ut = e, pt(!1), 0 === xt.avail_out)) return U; if (Ut - zt >= St - nt && (pt(!1), 0 === xt.avail_out)) return U } return pt(t == q), 0 === xt.avail_out ? t == q ? W : U : t == q ? X : H } function wt(t) { var e, n, r = Vt, i = Ut, o = Xt, a = Ut > St - nt ? Ut - (St - nt) : 0, s = Kt, c = Tt, l = Ut + et, u = Pt[i + o - 1], h = Pt[i + o]; Xt >= Qt && (r >>= 2), s > Wt && (s = Wt); do if (e = t, Pt[e + o] == h && Pt[e + o - 1] == u && Pt[e] == Pt[i] && Pt[++e] == Pt[i + 1]) { i += 2, e++; do; while (Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && Pt[++i] == Pt[++e] && i < l); if (n = et - (l - i), i = l - et, n > o) { if (Ht = t, o = n, n >= s) break; u = Pt[i + o - 1], h = Pt[i + o] } } while ((t = 65535 & Et[t & c]) > a && 0 !== --r); return o <= Wt ? o : Wt } function yt(t) { for (var e, n = 0; ;) { if (Wt < nt) { if (gt(), Wt < nt && t == C) return U; if (0 === Wt) break } if (Wt >= tt && (Ft = (Ft << jt ^ 255 & Pt[Ut + (tt - 1)]) & Dt, n = 65535 & Ot[Ft], Et[Ut & Tt] = Ot[Ft], Ot[Ft] = Ut), 0 !== n && (Ut - n & 65535) <= St - nt && Jt != k && (Nt = wt(n)), Nt >= tt) if (e = ct(Ut - Ht, Nt - tt), Wt -= Nt, Nt <= Yt && Wt >= tt) { Nt--; do Ut++, Ft = (Ft << jt ^ 255 & Pt[Ut + (tt - 1)]) & Dt, n = 65535 & Ot[Ft], Et[Ut & Tt] = Ot[Ft], Ot[Ft] = Ut; while (0 !== --Nt); Ut++ } else Ut += Nt, Nt = 0, Ft = 255 & Pt[Ut], Ft = (Ft << jt ^ 255 & Pt[Ut + 1]) & Dt; else e = ct(0, 255 & Pt[Ut]), Wt--, Ut++; if (e && (pt(!1), 0 === xt.avail_out)) return U } return pt(t == q), 0 === xt.avail_out ? t == q ? W : U : t == q ? X : H } function vt(t) { for (var e, n, r = 0; ;) { if (Wt < nt) { if (gt(), Wt < nt && t == C) return U; if (0 === Wt) break } if (Wt >= tt && (Ft = (Ft << jt ^ 255 & Pt[Ut + (tt - 1)]) & Dt, r = 65535 & Ot[Ft], Et[Ut & Tt] = Ot[Ft], Ot[Ft] = Ut), Xt = Nt, Lt = Ht, Nt = tt - 1, 0 !== r && Xt < Yt && (Ut - r & 65535) <= St - nt && (Jt != k && (Nt = wt(r)), Nt <= 5 && (Jt == x || Nt == tt && Ut - Ht > 4096) && (Nt = tt - 1)), Xt >= tt && Nt <= Xt) { n = Ut + Wt - tt, e = ct(Ut - 1 - Lt, Xt - tt), Wt -= Xt - 1, Xt -= 2; do ++Ut <= n && (Ft = (Ft << jt ^ 255 & Pt[Ut + (tt - 1)]) & Dt, r = 65535 & Ot[Ft], Et[Ut & Tt] = Ot[Ft], Ot[Ft] = Ut); while (0 !== --Xt); if (Mt = 0, Nt = tt - 1, Ut++, e && (pt(!1), 0 === xt.avail_out)) return U } else if (0 !== Mt) { if (e = ct(0, 255 & Pt[Ut - 1]), e && pt(!1), Ut++, Wt--, 0 === xt.avail_out) return U } else Mt = 1, Ut++, Wt-- } return 0 !== Mt && (e = ct(0, 255 & Pt[Ut - 1]), Mt = 0), pt(t == q), 0 === xt.avail_out ? t == q ? W : U : t == q ? X : H } function bt(e) { return e.total_in = e.total_out = 0, e.msg = null, ee.pending = 0, ee.pending_out = 0, kt = G, At = C, o(), t(), T } var xt, kt, _t, Ct, At, St, qt, Tt, Pt, It, Et, Ot, Ft, Rt, Bt, Dt, jt, zt, Nt, Lt, Mt, Ut, Ht, Wt, Xt, Vt, Yt, Gt, Jt, Qt, Kt, $t, Zt, te, ee = this, ne = new e, re = new e, ie = new e; ee.depth = []; var oe, ae, se, ce, le, ue, he, fe; ee.bl_count = [], ee.heap = [], $t = [], Zt = [], te = [], ee.pqdownheap = function (t, e) { for (var n = ee.heap, r = n[e], o = e << 1; o <= ee.heap_len && (o < ee.heap_len && i(t, n[o + 1], n[o], ee.depth) && o++, !i(t, r, n[o], ee.depth)) ;) n[e] = n[o], e = o, o <<= 1; n[e] = r }, ee.deflateInit = function (t, e, n, r, i, o) { return r || (r = Q), i || (i = D), o || (o = _), t.msg = null, e == b && (e = 6), i < 1 || i > B || r != Q || n < 9 || n > 15 || e < 0 || e > 9 || o < 0 || o > k ? E : (t.dstate = ee, qt = n, St = 1 << qt, Tt = St - 1, Bt = i + 7, Rt = 1 << Bt, Dt = Rt - 1, jt = Math.floor((Bt + tt - 1) / tt), Pt = new Uint8Array(2 * St), Et = [], Ot = [], ae = 1 << i + 6, ee.pending_buf = new Uint8Array(4 * ae), _t = 4 * ae, ce = Math.floor(ae / 2), oe = 3 * ae, Gt = e, Jt = o, Ct = 255 & r, bt(t)) }, ee.deflateEnd = function () { return kt != Y && kt != G && kt != J ? E : (ee.pending_buf = null, Ot = null, Et = null, Pt = null, ee.dstate = null, kt == G ? O : T) }, ee.deflateParams = function (t, e, n) { var r = T; return e == b && (e = 6), e < 0 || e > 9 || n < 0 || n > k ? E : (L[Gt].func != L[e].func && 0 !== t.total_in && (r = t.deflate(A)), Gt != e && (Gt = e, Yt = L[Gt].max_lazy, Qt = L[Gt].good_length, Kt = L[Gt].nice_length, Vt = L[Gt].max_chain), Jt = n, r) }, ee.deflateSetDictionary = function (t, e, n) { var r, i = n, o = 0; if (!e || kt != Y) return E; if (i < tt) return T; for (i > St - nt && (i = St - nt, o = n - i), Pt.set(e.subarray(o, o + i), 0), Ut = i, zt = i, Ft = 255 & Pt[0], Ft = (Ft << jt ^ 255 & Pt[1]) & Dt, r = 0; r <= i - tt; r++) Ft = (Ft << jt ^ 255 & Pt[r + (tt - 1)]) & Dt, Et[r & Tt] = Ot[Ft], Ot[Ft] = r; return T }, ee.deflate = function (t, e) { var n, r, i, o, a; if (e > q || e < 0) return E; if (!t.next_out || !t.next_in && 0 !== t.avail_in || kt == J && e != q) return t.msg = M[I - E], E; if (0 === t.avail_out) return t.msg = M[I - F], F; if (xt = t, o = At, At = e, kt == Y && (r = Q + (qt - 8 << 4) << 8, i = (Gt - 1 & 255) >> 1, i > 3 && (i = 3), r |= i << 6, 0 !== Ut && (r |= V), r += 31 - r % 31, kt = G, g(r)), 0 !== ee.pending) { if (xt.flush_pending(), 0 === xt.avail_out) return At = -1, T } else if (0 === xt.avail_in && e <= o && e != q) return xt.msg = M[I - F], F; if (kt == J && 0 !== xt.avail_in) return t.msg = M[I - F], F; if (0 !== xt.avail_in || 0 !== Wt || e != C && kt != J) { switch (a = -1, L[Gt].func) { case j: a = mt(e); break; case z: a = yt(e); break; case N: a = vt(e) } if (a != W && a != X || (kt = J), a == U || a == W) return 0 === xt.avail_out && (At = -1), T; if (a == H) { if (e == A) st(); else if (ft(0, 0, !1), e == S) for (n = 0; n < Rt; n++) Ot[n] = 0; if (xt.flush_pending(), 0 === xt.avail_out) return At = -1, T } } return e != q ? T : P } } function a() { var t = this; t.next_in_index = 0, t.next_out_index = 0, t.avail_in = 0, t.total_in = 0, t.avail_out = 0, t.total_out = 0 } var s = 15, c = 30, l = 19, u = 29, h = 256, f = h + 1 + u, d = 2 * f + 1, p = 256, g = 7, m = 16, w = 17, y = 18, v = 16, b = -1, x = 1, k = 2, _ = 0, C = 0, A = 1, S = 3, q = 4, T = 0, P = 1, I = 2, E = -2, O = -3, F = -5, R = [0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]; e._length_code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28], e.base_length = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0], e.base_dist = [0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576], e.d_code = function (t) { return t < 256 ? R[t] : R[256 + (t >>> 7)] }, e.extra_lbits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], e.extra_dbits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], e.extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], e.bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], n.static_ltree = [12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8], n.static_dtree = [0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5], n.static_l_desc = new n(n.static_ltree, e.extra_lbits, h + 1, f, s), n.static_d_desc = new n(n.static_dtree, e.extra_dbits, 0, c, s), n.static_bl_desc = new n(null, e.extra_blbits, 0, l, g); var B = 9, D = 8, j = 0, z = 1, N = 2, L = [new r(0, 0, 0, 0, j), new r(4, 4, 8, 4, z), new r(4, 5, 16, 8, z), new r(4, 6, 32, 32, z), new r(4, 4, 16, 16, N), new r(8, 16, 32, 32, N), new r(8, 16, 128, 128, N), new r(8, 32, 128, 256, N), new r(32, 128, 258, 1024, N), new r(32, 258, 258, 4096, N)], M = ["need dictionary", "stream end", "", "", "stream error", "data error", "", "buffer error", "", ""], U = 0, H = 1, W = 2, X = 3, V = 32, Y = 42, G = 113, J = 666, Q = 8, K = 0, $ = 1, Z = 2, tt = 3, et = 258, nt = et + tt + 1; return a.prototype = { deflateInit: function (t, e) { var n = this; return n.dstate = new o, e || (e = s), n.dstate.deflateInit(n, t, e) }, deflate: function (t) { var e = this; return e.dstate ? e.dstate.deflate(e, t) : E }, deflateEnd: function () { var t = this; if (!t.dstate) return E; var e = t.dstate.deflateEnd(); return t.dstate = null, e }, deflateParams: function (t, e) { var n = this; return n.dstate ? n.dstate.deflateParams(n, t, e) : E }, deflateSetDictionary: function (t, e) { var n = this; return n.dstate ? n.dstate.deflateSetDictionary(n, t, e) : E }, read_buf: function (t, e, n) { var r = this, i = r.avail_in; return i > n && (i = n), 0 === i ? 0 : (r.avail_in -= i, t.set(r.next_in.subarray(r.next_in_index, r.next_in_index + i), e), r.next_in_index += i, r.total_in += i, i) }, flush_pending: function () { var t = this, e = t.dstate.pending; e > t.avail_out && (e = t.avail_out), 0 !== e && (t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out, t.dstate.pending_out + e), t.next_out_index), t.next_out_index += e, t.dstate.pending_out += e, t.total_out += e, t.avail_out -= e, t.dstate.pending -= e, 0 === t.dstate.pending && (t.dstate.pending_out = 0)) } }, function (t) { var e = this, n = new a, r = 512, i = C, o = new Uint8Array(r); "undefined" == typeof t && (t = b), n.deflateInit(t), n.next_out = o, e.append = function (t, e) { var a, s, c = [], l = 0, u = 0, h = 0; if (t.length) { n.next_in_index = 0, n.next_in = t, n.avail_in = t.length; do { if (n.next_out_index = 0, n.avail_out = r, a = n.deflate(i), a != T) throw "deflating: " + n.msg; n.next_out_index && (n.next_out_index == r ? c.push(new Uint8Array(o)) : c.push(new Uint8Array(o.subarray(0, n.next_out_index)))), h += n.next_out_index, e && n.next_in_index > 0 && n.next_in_index != l && (e(n.next_in_index), l = n.next_in_index) } while (n.avail_in > 0 || 0 === n.avail_out); return s = new Uint8Array(h), c.forEach(function (t) { s.set(t, u), u += t.length }), s } }, e.flush = function () { var t, e, i = [], a = 0, s = 0; do { if (n.next_out_index = 0, n.avail_out = r, t = n.deflate(q), t != P && t != T) throw "deflating: " + n.msg; r - n.avail_out > 0 && i.push(new Uint8Array(o.subarray(0, n.next_out_index))), s += n.next_out_index } while (n.avail_in > 0 || 0 === n.avail_out); return n.deflateEnd(), e = new Uint8Array(s), i.forEach(function (t) { e.set(t, a), a += t.length }), e } } }(void 0);/*
html2canvas 0.5.0-beta3
Copyright (c) 2016 Niklas von Hertzen
Released under License
*/
!function (t) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else { var e; "undefined" != typeof window ? e = window : "undefined" != typeof global ? e = global : "undefined" != typeof self && (e = self), e.html2canvas = t() } }(function () {
var t; return function t(e, n, r) { function i(a, s) { if (!n[a]) { if (!e[a]) { var c = "function" == typeof require && require; if (!s && c) return c(a, !0); if (o) return o(a, !0); var l = new Error("Cannot find module '" + a + "'"); throw l.code = "MODULE_NOT_FOUND", l } var u = n[a] = { exports: {} }; e[a][0].call(u.exports, function (t) { var n = e[a][1][t]; return i(n ? n : t) }, u, u.exports, t, e, n, r) } return n[a].exports } for (var o = "function" == typeof require && require, a = 0; a < r.length; a++) i(r[a]); return i }({
1: [function (e, n, r) { (function (e) { !function (i) { function o(t) { throw RangeError(R[t]) } function a(t, e) { for (var n = t.length; n--;) t[n] = e(t[n]); return t } function s(t, e) { return a(t.split(F), e).join(".") } function c(t) { for (var e, n, r = [], i = 0, o = t.length; i < o;) e = t.charCodeAt(i++), e >= 55296 && e <= 56319 && i < o ? (n = t.charCodeAt(i++), 56320 == (64512 & n) ? r.push(((1023 & e) << 10) + (1023 & n) + 65536) : (r.push(e), i--)) : r.push(e); return r } function l(t) { return a(t, function (t) { var e = ""; return t > 65535 && (t -= 65536, e += j(t >>> 10 & 1023 | 55296), t = 56320 | 1023 & t), e += j(t) }).join("") } function u(t) { return t - 48 < 10 ? t - 22 : t - 65 < 26 ? t - 65 : t - 97 < 26 ? t - 97 : _ } function h(t, e) { return t + 22 + 75 * (t < 26) - ((0 != e) << 5) } function f(t, e, n) { var r = 0; for (t = n ? D(t / q) : t >> 1, t += D(t / e) ; t > B * A >> 1; r += _) t = D(t / B); return D(r + (B + 1) * t / (t + S)) } function d(t) { var e, n, r, i, a, s, c, h, d, p, g = [], m = t.length, w = 0, y = P, v = T; for (n = t.lastIndexOf(I), n < 0 && (n = 0), r = 0; r < n; ++r) t.charCodeAt(r) >= 128 && o("not-basic"), g.push(t.charCodeAt(r)); for (i = n > 0 ? n + 1 : 0; i < m;) { for (a = w, s = 1, c = _; i >= m && o("invalid-input"), h = u(t.charCodeAt(i++)), (h >= _ || h > D((k - w) / s)) && o("overflow"), w += h * s, d = c <= v ? C : c >= v + A ? A : c - v, !(h < d) ; c += _) p = _ - d, s > D(k / p) && o("overflow"), s *= p; e = g.length + 1, v = f(w - a, e, 0 == a), D(w / e) > k - y && o("overflow"), y += D(w / e), w %= e, g.splice(w++, 0, y) } return l(g) } function p(t) { var e, n, r, i, a, s, l, u, d, p, g, m, w, y, v, b = []; for (t = c(t), m = t.length, e = P, n = 0, a = T, s = 0; s < m; ++s) g = t[s], g < 128 && b.push(j(g)); for (r = i = b.length, i && b.push(I) ; r < m;) { for (l = k, s = 0; s < m; ++s) g = t[s], g >= e && g < l && (l = g); for (w = r + 1, l - e > D((k - n) / w) && o("overflow"), n += (l - e) * w, e = l, s = 0; s < m; ++s) if (g = t[s], g < e && ++n > k && o("overflow"), g == e) { for (u = n, d = _; p = d <= a ? C : d >= a + A ? A : d - a, !(u < p) ; d += _) v = u - p, y = _ - p, b.push(j(h(p + v % y, 0))), u = D(v / y); b.push(j(h(u, 0))), a = f(n, w, r == i), n = 0, ++r } ++n, ++e } return b.join("") } function g(t) { return s(t, function (t) { return E.test(t) ? d(t.slice(4).toLowerCase()) : t }) } function m(t) { return s(t, function (t) { return O.test(t) ? "xn--" + p(t) : t }) } var w = "object" == typeof r && r, y = "object" == typeof n && n && n.exports == w && n, v = "object" == typeof e && e; v.global !== v && v.window !== v || (i = v); var b, x, k = 2147483647, _ = 36, C = 1, A = 26, S = 38, q = 700, T = 72, P = 128, I = "-", E = /^xn--/, O = /[^ -~]/, F = /\x2E|\u3002|\uFF0E|\uFF61/g, R = { overflow: "Overflow: input needs wider integers to process", "not-basic": "Illegal input >= 0x80 (not a basic code point)", "invalid-input": "Invalid input" }, B = _ - C, D = Math.floor, j = String.fromCharCode; if (b = { version: "1.2.4", ucs2: { decode: c, encode: l }, decode: d, encode: p, toASCII: m, toUnicode: g }, "function" == typeof t && "object" == typeof t.amd && t.amd) t("punycode", function () { return b }); else if (w && !w.nodeType) if (y) y.exports = b; else for (x in b) b.hasOwnProperty(x) && (w[x] = b[x]); else i.punycode = b }(this) }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}) }, {}], 2: [function (t, e, n) { function r(t, e, n) { !t.defaultView || e === t.defaultView.pageXOffset && n === t.defaultView.pageYOffset || t.defaultView.scrollTo(e, n) } function i(t, e) { try { e && (e.width = t.width, e.height = t.height, e.getContext("2d").putImageData(t.getContext("2d").getImageData(0, 0, t.width, t.height), 0, 0)) } catch (e) { s("Unable to copy canvas content from", t, e) } } function o(t, e) { for (var n = 3 === t.nodeType ? document.createTextNode(t.nodeValue) : t.cloneNode(!1), r = t.firstChild; r;) e !== !0 && 1 === r.nodeType && "SCRIPT" === r.nodeName || n.appendChild(o(r, e)), r = r.nextSibling; return 1 === t.nodeType && (n._scrollTop = t.scrollTop, n._scrollLeft = t.scrollLeft, "CANVAS" === t.nodeName ? i(t, n) : "TEXTAREA" !== t.nodeName && "SELECT" !== t.nodeName || (n.value = t.value)), n } function a(t) { if (1 === t.nodeType) { t.scrollTop = t._scrollTop, t.scrollLeft = t._scrollLeft; for (var e = t.firstChild; e;) a(e), e = e.nextSibling } } var s = t("./log"); e.exports = function (t, e, n, i, s, c, l) { var u = o(t.documentElement, s.javascriptEnabled), h = e.createElement("iframe"); return h.className = "html2canvas-container", h.style.visibility = "hidden", h.style.position = "fixed", h.style.left = "-10000px", h.style.top = "0px", h.style.border = "0", h.width = n, h.height = i, h.scrolling = "no", e.body.appendChild(h), new Promise(function (e) { var n = h.contentWindow.document; h.contentWindow.onload = h.onload = function () { var t = setInterval(function () { n.body.childNodes.length > 0 && (a(n.documentElement), clearInterval(t), "view" === s.type && (h.contentWindow.scrollTo(c, l), !/(iPad|iPhone|iPod)/g.test(navigator.userAgent) || h.contentWindow.scrollY === l && h.contentWindow.scrollX === c || (n.documentElement.style.top = -l + "px", n.documentElement.style.left = -c + "px", n.documentElement.style.position = "absolute")), e(h)) }, 50) }, n.open(), n.write(""), r(t, c, l), n.replaceChild(n.adoptNode(u), n.documentElement), n.close() }) } }, { "./log": 13 }], 3: [function (t, e, n) { function r(t) { this.r = 0, this.g = 0, this.b = 0, this.a = null; this.fromArray(t) || this.namedColor(t) || this.rgb(t) || this.rgba(t) || this.hex6(t) || this.hex3(t) } r.prototype.darken = function (t) { var e = 1 - t; return new r([Math.round(this.r * e), Math.round(this.g * e), Math.round(this.b * e), this.a]) }, r.prototype.isTransparent = function () { return 0 === this.a }, r.prototype.isBlack = function () { return 0 === this.r && 0 === this.g && 0 === this.b }, r.prototype.fromArray = function (t) { return Array.isArray(t) && (this.r = Math.min(t[0], 255), this.g = Math.min(t[1], 255), this.b = Math.min(t[2], 255), t.length > 3 && (this.a = t[3])), Array.isArray(t) }; var i = /^#([a-f0-9]{3})$/i; r.prototype.hex3 = function (t) { var e = null; return null !== (e = t.match(i)) && (this.r = parseInt(e[1][0] + e[1][0], 16), this.g = parseInt(e[1][1] + e[1][1], 16), this.b = parseInt(e[1][2] + e[1][2], 16)), null !== e }; var o = /^#([a-f0-9]{6})$/i; r.prototype.hex6 = function (t) { var e = null; return null !== (e = t.match(o)) && (this.r = parseInt(e[1].substring(0, 2), 16), this.g = parseInt(e[1].substring(2, 4), 16), this.b = parseInt(e[1].substring(4, 6), 16)), null !== e }; var a = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/; r.prototype.rgb = function (t) { var e = null; return null !== (e = t.match(a)) && (this.r = Number(e[1]), this.g = Number(e[2]), this.b = Number(e[3])), null !== e }; var s = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d?\.?\d+)\s*\)$/; r.prototype.rgba = function (t) { var e = null; return null !== (e = t.match(s)) && (this.r = Number(e[1]), this.g = Number(e[2]), this.b = Number(e[3]), this.a = Number(e[4])), null !== e }, r.prototype.toString = function () { return null !== this.a && 1 !== this.a ? "rgba(" + [this.r, this.g, this.b, this.a].join(",") + ")" : "rgb(" + [this.r, this.g, this.b].join(",") + ")" }, r.prototype.namedColor = function (t) { t = t.toLowerCase(); var e = c[t]; if (e) this.r = e[0], this.g = e[1], this.b = e[2]; else if ("transparent" === t) return this.r = this.g = this.b = this.a = 0, !0; return !!e }, r.prototype.isColor = !0; var c = { aliceblue: [240, 248, 255], antiquewhite: [250, 235, 215], aqua: [0, 255, 255], aquamarine: [127, 255, 212], azure: [240, 255, 255], beige: [245, 245, 220], bisque: [255, 228, 196], black: [0, 0, 0], blanchedalmond: [255, 235, 205], blue: [0, 0, 255], blueviolet: [138, 43, 226], brown: [165, 42, 42], burlywood: [222, 184, 135], cadetblue: [95, 158, 160], chartreuse: [127, 255, 0], chocolate: [210, 105, 30], coral: [255, 127, 80], cornflowerblue: [100, 149, 237], cornsilk: [255, 248, 220], crimson: [220, 20, 60], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgoldenrod: [184, 134, 11], darkgray: [169, 169, 169], darkgreen: [0, 100, 0], darkgrey: [169, 169, 169], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkseagreen: [143, 188, 143], darkslateblue: [72, 61, 139], darkslategray: [47, 79, 79], darkslategrey: [47, 79, 79], darkturquoise: [0, 206, 209], darkviolet: [148, 0, 211], deeppink: [255, 20, 147], deepskyblue: [0, 191, 255], dimgray: [105, 105, 105], dimgrey: [105, 105, 105], dodgerblue: [30, 144, 255], firebrick: [178, 34, 34], floralwhite: [255, 250, 240], forestgreen: [34, 139, 34], fuchsia: [255, 0, 255], gainsboro: [220, 220, 220], ghostwhite: [248, 248, 255], gold: [255, 215, 0], goldenrod: [218, 165, 32], gray: [128, 128, 128], green: [0, 128, 0], greenyellow: [173, 255, 47], grey: [128, 128, 128], honeydew: [240, 255, 240], hotpink: [255, 105, 180], indianred: [205, 92, 92], indigo: [75, 0, 130], ivory: [255, 255, 240], khaki: [240, 230, 140], lavender: [230, 230, 250], lavenderblush: [255, 240, 245], lawngreen: [124, 252, 0], lemonchiffon: [255, 250, 205], lightblue: [173, 216, 230], lightcoral: [240, 128, 128], lightcyan: [224, 255, 255], lightgoldenrodyellow: [250, 250, 210], lightgray: [211, 211, 211], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightsalmon: [255, 160, 122], lightseagreen: [32, 178, 170], lightskyblue: [135, 206, 250], lightslategray: [119, 136, 153], lightslategrey: [119, 136, 153], lightsteelblue: [176, 196, 222], lightyellow: [255, 255, 224], lime: [0, 255, 0], limegreen: [50, 205, 50], linen: [250, 240, 230], magenta: [255, 0, 255], maroon: [128, 0, 0], mediumaquamarine: [102, 205, 170], mediumblue: [0, 0, 205], mediumorchid: [186, 85, 211], mediumpurple: [147, 112, 219], mediumseagreen: [60, 179, 113], mediumslateblue: [123, 104, 238], mediumspringgreen: [0, 250, 154], mediumturquoise: [72, 209, 204], mediumvioletred: [199, 21, 133], midnightblue: [25, 25, 112], mintcream: [245, 255, 250], mistyrose: [255, 228, 225], moccasin: [255, 228, 181], navajowhite: [255, 222, 173], navy: [0, 0, 128], oldlace: [253, 245, 230], olive: [128, 128, 0], olivedrab: [107, 142, 35], orange: [255, 165, 0], orangered: [255, 69, 0], orchid: [218, 112, 214], palegoldenrod: [238, 232, 170], palegreen: [152, 251, 152], paleturquoise: [175, 238, 238], palevioletred: [219, 112, 147], papayawhip: [255, 239, 213], peachpuff: [255, 218, 185], peru: [205, 133, 63], pink: [255, 192, 203], plum: [221, 160, 221], powderblue: [176, 224, 230], purple: [128, 0, 128], rebeccapurple: [102, 51, 153], red: [255, 0, 0], rosybrown: [188, 143, 143], royalblue: [65, 105, 225], saddlebrown: [139, 69, 19], salmon: [250, 128, 114], sandybrown: [244, 164, 96], seagreen: [46, 139, 87], seashell: [255, 245, 238], sienna: [160, 82, 45], silver: [192, 192, 192], skyblue: [135, 206, 235], slateblue: [106, 90, 205], slategray: [112, 128, 144], slategrey: [112, 128, 144], snow: [255, 250, 250], springgreen: [0, 255, 127], steelblue: [70, 130, 180], tan: [210, 180, 140], teal: [0, 128, 128], thistle: [216, 191, 216], tomato: [255, 99, 71], turquoise: [64, 224, 208], violet: [238, 130, 238], wheat: [245, 222, 179], white: [255, 255, 255], whitesmoke: [245, 245, 245], yellow: [255, 255, 0], yellowgreen: [154, 205, 50] }; e.exports = r }, {}], 4: [function (e, n, r) { function i(t, e) { var n = _++; if (e = e || {}, e.logging && (w.options.logging = !0, w.options.start = Date.now()), e.async = "undefined" == typeof e.async || e.async, e.allowTaint = "undefined" != typeof e.allowTaint && e.allowTaint, e.removeContainer = "undefined" == typeof e.removeContainer || e.removeContainer, e.javascriptEnabled = "undefined" != typeof e.javascriptEnabled && e.javascriptEnabled, e.imageTimeout = "undefined" == typeof e.imageTimeout ? 1e4 : e.imageTimeout, e.renderer = "function" == typeof e.renderer ? e.renderer : d, e.strict = !!e.strict, "string" == typeof t) { if ("string" != typeof e.proxy) return Promise.reject("Proxy must be used when rendering url"); var r = null != e.width ? e.width : window.innerWidth, i = null != e.height ? e.height : window.innerHeight; return b(h(t), e.proxy, document, r, i, e).then(function (t) { return a(t.contentWindow.document.documentElement, t, e, r, i) }) } var s = (void 0 === t ? [document.documentElement] : t.length ? t : [t])[0]; return s.setAttribute(k + n, n), o(s.ownerDocument, e, s.ownerDocument.defaultView.innerWidth, s.ownerDocument.defaultView.innerHeight, n).then(function (t) { return "function" == typeof e.onrendered && (w("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas"), e.onrendered(t)), t }) } function o(t, e, n, r, i) { return v(t, t, n, r, e, t.defaultView.pageXOffset, t.defaultView.pageYOffset).then(function (o) { w("Document cloned"); var s = k + i, c = "[" + s + "='" + i + "']"; t.querySelector(c).removeAttribute(s); var l = o.contentWindow, u = l.document.querySelector(c), h = "function" == typeof e.onclone ? Promise.resolve(e.onclone(l.document)) : Promise.resolve(!0); return h.then(function () { return a(u, o, e, n, r) }) }) } function a(t, e, n, r, i) { var o = e.contentWindow, a = new f(o.document), h = new p(n, a), d = x(t), m = "view" === n.type ? r : l(o.document), y = "view" === n.type ? i : u(o.document), v = new n.renderer(m, y, h, n, document), b = new g(t, v, a, h, n); return b.ready.then(function () { w("Finished rendering"); var r; return r = "view" === n.type ? c(v.canvas, { width: v.canvas.width, height: v.canvas.height, top: 0, left: 0, x: 0, y: 0 }) : t === o.document.body || t === o.document.documentElement || null != n.canvas ? v.canvas : c(v.canvas, { width: null != n.width ? n.width : d.width, height: null != n.height ? n.height : d.height, top: d.top, left: d.left, x: 0, y: 0 }), s(e, n), r }) } function s(t, e) { e.removeContainer && (t.parentNode.removeChild(t), w("Cleaned up container")) } function c(t, e) { var n = document.createElement("canvas"), r = Math.min(t.width - 1, Math.max(0, e.left)), i = Math.min(t.width, Math.max(1, e.left + e.width)), o = Math.min(t.height - 1, Math.max(0, e.top)), a = Math.min(t.height, Math.max(1, e.top + e.height)); n.width = e.width, n.height = e.height; var s = i - r, c = a - o; return w("Cropping canvas at:", "left:", e.left, "top:", e.top, "width:", s, "height:", c), w("Resulting crop with width", e.width, "and height", e.height, "with x", r, "and y", o), n.getContext("2d").drawImage(t, r, o, s, c, e.x, e.y, s, c), n } function l(t) { return Math.max(Math.max(t.body.scrollWidth, t.documentElement.scrollWidth), Math.max(t.body.offsetWidth, t.documentElement.offsetWidth), Math.max(t.body.clientWidth, t.documentElement.clientWidth)) } function u(t) { return Math.max(Math.max(t.body.scrollHeight, t.documentElement.scrollHeight), Math.max(t.body.offsetHeight, t.documentElement.offsetHeight), Math.max(t.body.clientHeight, t.documentElement.clientHeight)) } function h(t) { var e = document.createElement("a"); return e.href = t, e.href = e.href, e } var f = e("./support"), d = e("./renderers/canvas"), p = e("./imageloader"), g = e("./nodeparser"), m = e("./nodecontainer"), w = e("./log"), y = e("./utils"), v = e("./clone"), b = e("./proxy").loadUrlDocument, x = y.getBounds, k = "data-html2canvas-node", _ = 0; i.CanvasRenderer = d, i.NodeContainer = m, i.log = w, i.utils = y; var C = "undefined" == typeof document || "function" != typeof Object.create || "function" != typeof document.createElement("canvas").getContext ? function () { return Promise.reject("No canvas support") } : i; n.exports = C, "function" == typeof t && t.amd && t("html2canvas", [], function () { return C }) }, { "./clone": 2, "./imageloader": 11, "./log": 13, "./nodecontainer": 14, "./nodeparser": 15, "./proxy": 16, "./renderers/canvas": 20, "./support": 22, "./utils": 26 }], 5: [function (t, e, n) { function r(t) { if (this.src = t, i("DummyImageContainer for", t), !this.promise || !this.image) { i("Initiating DummyImageContainer"), r.prototype.image = new Image; var e = this.image; r.prototype.promise = new Promise(function (t, n) { e.onload = t, e.onerror = n, e.src = o(), e.complete === !0 && t(e) }) } } var i = t("./log"), o = t("./utils").smallImage; e.exports = r }, { "./log": 13, "./utils": 26 }], 6: [function (t, e, n) { function r(t, e) { var n, r, o = document.createElement("div"), a = document.createElement("img"), s = document.createElement("span"), c = "Hidden Text"; o.style.visibility = "hidden", o.style.fontFamily = t, o.style.fontSize = e, o.style.margin = 0, o.style.padding = 0, document.body.appendChild(o), a.src = i(), a.width = 1, a.height = 1, a.style.margin = 0, a.style.padding = 0, a.style.verticalAlign = "baseline", s.style.fontFamily = t, s.style.fontSize = e, s.style.margin = 0, s.style.padding = 0, s.appendChild(document.createTextNode(c)), o.appendChild(s), o.appendChild(a), n = a.offsetTop - s.offsetTop + 1, o.removeChild(s), o.appendChild(document.createTextNode(c)), o.style.lineHeight = "normal", a.style.verticalAlign = "super", r = a.offsetTop - o.offsetTop + 1, document.body.removeChild(o), this.baseline = n, this.lineWidth = 1, this.middle = r } var i = t("./utils").smallImage; e.exports = r }, { "./utils": 26 }], 7: [function (t, e, n) { function r() { this.data = {} } var i = t("./font"); r.prototype.getMetrics = function (t, e) { return void 0 === this.data[t + "-" + e] && (this.data[t + "-" + e] = new i(t, e)), this.data[t + "-" + e] }, e.exports = r }, { "./font": 6 }], 8: [function (t, e, n) { function r(e, n, r) { this.image = null, this.src = e; var i = this, a = o(e); this.promise = (n ? new Promise(function (t) { "about:blank" === e.contentWindow.document.URL || null == e.contentWindow.document.documentElement ? e.contentWindow.onload = e.onload = function () { t(e) } : t(e) }) : this.proxyLoad(r.proxy, a, r)).then(function (e) { var n = t("./core"); return n(e.contentWindow.document.documentElement, { type: "view", width: e.width, height: e.height, proxy: r.proxy, javascriptEnabled: r.javascriptEnabled, removeContainer: r.removeContainer, allowTaint: r.allowTaint, imageTimeout: r.imageTimeout / 2 }) }).then(function (t) { return i.image = t }) } var i = t("./utils"), o = i.getBounds, a = t("./proxy").loadUrlDocument; r.prototype.proxyLoad = function (t, e, n) { var r = this.src; return a(r.src, t, r.ownerDocument, e.width, e.height, n) }, e.exports = r }, { "./core": 4, "./proxy": 16, "./utils": 26 }], 9: [function (t, e, n) { function r(t) { this.src = t.value, this.colorStops = [], this.type = null, this.x0 = .5, this.y0 = .5, this.x1 = .5, this.y1 = .5, this.promise = Promise.resolve(!0) } r.TYPES = { LINEAR: 1, RADIAL: 2 }, r.REGEXP_COLORSTOP = /^\s*(rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}(?:,\s*[0-9\.]+)?\s*\)|[a-z]{3,20}|#[a-f0-9]{3,6})(?:\s+(\d{1,3}(?:\.\d+)?)(%|px)?)?(?:\s|$)/i, e.exports = r }, {}], 10: [function (t, e, n) { function r(t, e) { this.src = t, this.image = new Image; var n = this; this.tainted = null, this.promise = new Promise(function (r, i) { n.image.onload = r, n.image.onerror = i, e && (n.image.crossOrigin = "anonymous"), n.image.src = t, n.image.complete === !0 && r(n.image) }) } e.exports = r }, {}], 11: [function (t, e, n) { function r(t, e) { this.link = null, this.options = t, this.support = e, this.origin = this.getOrigin(window.location.href) } var i = t("./log"), o = t("./imagecontainer"), a = t("./dummyimagecontainer"), s = t("./proxyimagecontainer"), c = t("./framecontainer"), l = t("./svgcontainer"), u = t("./svgnodecontainer"), h = t("./lineargradientcontainer"), f = t("./webkitgradientcontainer"), d = t("./utils").bind; r.prototype.findImages = function (t) { var e = []; return t.reduce(function (t, e) { switch (e.node.nodeName) { case "IMG": return t.concat([{ args: [e.node.src], method: "url" }]); case "svg": case "IFRAME": return t.concat([{ args: [e.node], method: e.node.nodeName }]) } return t }, []).forEach(this.addImage(e, this.loadImage), this), e }, r.prototype.findBackgroundImage = function (t, e) { return e.parseBackgroundImages().filter(this.hasImageBackground).forEach(this.addImage(t, this.loadImage), this), t }, r.prototype.addImage = function (t, e) { return function (n) { n.args.forEach(function (r) { this.imageExists(t, r) || (t.splice(0, 0, e.call(this, n)), i("Added image #" + t.length, "string" == typeof r ? r.substring(0, 100) : r)) }, this) } }, r.prototype.hasImageBackground = function (t) { return "none" !== t.method }, r.prototype.loadImage = function (t) { if ("url" === t.method) { var e = t.args[0]; return !this.isSVG(e) || this.support.svg || this.options.allowTaint ? e.match(/data:image\/.*;base64,/i) ? new o(e.replace(/url\(['"]{0,}|['"]{0,}\)$/gi, ""), !1) : this.isSameOrigin(e) || this.options.allowTaint === !0 || this.isSVG(e) ? new o(e, !1) : this.support.cors && !this.options.allowTaint && this.options.useCORS ? new o(e, !0) : this.options.proxy ? new s(e, this.options.proxy) : new a(e) : new l(e) } return "linear-gradient" === t.method ? new h(t) : "gradient" === t.method ? new f(t) : "svg" === t.method ? new u(t.args[0], this.support.svg) : "IFRAME" === t.method ? new c(t.args[0], this.isSameOrigin(t.args[0].src), this.options) : new a(t) }, r.prototype.isSVG = function (t) { return "svg" === t.substring(t.length - 3).toLowerCase() || l.prototype.isInline(t) }, r.prototype.imageExists = function (t, e) { return t.some(function (t) { return t.src === e }) }, r.prototype.isSameOrigin = function (t) { return this.getOrigin(t) === this.origin }, r.prototype.getOrigin = function (t) { var e = this.link || (this.link = document.createElement("a")); return e.href = t, e.href = e.href, e.protocol + e.hostname + e.port }, r.prototype.getPromise = function (t) { return this.timeout(t, this.options.imageTimeout).catch(function () { var e = new a(t.src); return e.promise.then(function (e) { t.image = e }) }) }, r.prototype.get = function (t) { var e = null; return this.images.some(function (n) { return (e = n).src === t }) ? e : null }, r.prototype.fetch = function (t) { return this.images = t.reduce(d(this.findBackgroundImage, this), this.findImages(t)), this.images.forEach(function (t, e) { t.promise.then(function () { i("Succesfully loaded image #" + (e + 1), t) }, function (n) { i("Failed loading image #" + (e + 1), t, n) }) }), this.ready = Promise.all(this.images.map(this.getPromise, this)), i("Finished searching images"), this }, r.prototype.timeout = function (t, e) { var n, r = Promise.race([t.promise, new Promise(function (r, o) { n = setTimeout(function () { i("Timed out loading image", t), o(t) }, e) })]).then(function (t) { return clearTimeout(n), t }); return r.catch(function () { clearTimeout(n) }), r }, e.exports = r }, { "./dummyimagecontainer": 5, "./framecontainer": 8, "./imagecontainer": 10, "./lineargradientcontainer": 12, "./log": 13, "./proxyimagecontainer": 17, "./svgcontainer": 23, "./svgnodecontainer": 24, "./utils": 26, "./webkitgradientcontainer": 27 }], 12: [function (t, e, n) { function r(t) { i.apply(this, arguments), this.type = i.TYPES.LINEAR; var e = r.REGEXP_DIRECTION.test(t.args[0]) || !i.REGEXP_COLORSTOP.test(t.args[0]); e ? t.args[0].split(/\s+/).reverse().forEach(function (t, e) { switch (t) { case "left": this.x0 = 0, this.x1 = 1; break; case "top": this.y0 = 0, this.y1 = 1; break; case "right": this.x0 = 1, this.x1 = 0; break; case "bottom": this.y0 = 1, this.y1 = 0; break; case "to": var n = this.y0, r = this.x0; this.y0 = this.y1, this.x0 = this.x1, this.x1 = r, this.y1 = n; break; case "center": break; default: var i = .01 * parseFloat(t, 10); if (isNaN(i)) break; 0 === e ? (this.y0 = i, this.y1 = 1 - this.y0) : (this.x0 = i, this.x1 = 1 - this.x0) } }, this) : (this.y0 = 0, this.y1 = 1), this.colorStops = t.args.slice(e ? 1 : 0).map(function (t) { var e = t.match(i.REGEXP_COLORSTOP), n = +e[2], r = 0 === n ? "%" : e[3]; return { color: new o(e[1]), stop: "%" === r ? n / 100 : null } }), null === this.colorStops[0].stop && (this.colorStops[0].stop = 0), null === this.colorStops[this.colorStops.length - 1].stop && (this.colorStops[this.colorStops.length - 1].stop = 1), this.colorStops.forEach(function (t, e) { null === t.stop && this.colorStops.slice(e).some(function (n, r) { return null !== n.stop && (t.stop = (n.stop - this.colorStops[e - 1].stop) / (r + 1) + this.colorStops[e - 1].stop, !0) }, this) }, this) } var i = t("./gradientcontainer"), o = t("./color"); r.prototype = Object.create(i.prototype), r.REGEXP_DIRECTION = /^\s*(?:to|left|right|top|bottom|center|\d{1,3}(?:\.\d+)?%?)(?:\s|$)/i, e.exports = r }, { "./color": 3, "./gradientcontainer": 9 }], 13: [function (t, e, n) { var r = function () { r.options.logging && window.console && window.console.log && Function.prototype.bind.call(window.console.log, window.console).apply(window.console, [Date.now() - r.options.start + "ms", "html2canvas:"].concat([].slice.call(arguments, 0))) }; r.options = { logging: !1 }, e.exports = r }, {}], 14: [function (t, e, n) { function r(t, e) { this.node = t, this.parent = e, this.stack = null, this.bounds = null, this.borders = null, this.clip = [], this.backgroundClip = [], this.offsetBounds = null, this.visible = null, this.computedStyles = null, this.colors = {}, this.styles = {}, this.backgroundImages = null, this.transformData = null, this.transformMatrix = null, this.isPseudoElement = !1, this.opacity = null } function i(t) { var e = t.options[t.selectedIndex || 0]; return e ? e.text || "" : "" } function o(t) { if (t && "matrix" === t[1]) return t[2].split(",").map(function (t) { return parseFloat(t.trim()) }); if (t && "matrix3d" === t[1]) { var e = t[2].split(",").map(function (t) { return parseFloat(t.trim()) }); return [e[0], e[1], e[4], e[5], e[12], e[13]] } } function a(t) { return t.toString().indexOf("%") !== -1 } function s(t) { return t.replace("px", "") } function c(t) { return parseFloat(t) } var l = t("./color"), u = t("./utils"), h = u.getBounds, f = u.parseBackgrounds, d = u.offsetBounds; r.prototype.cloneTo = function (t) { t.visible = this.visible, t.borders = this.borders, t.bounds = this.bounds, t.clip = this.clip, t.backgroundClip = this.backgroundClip, t.computedStyles = this.computedStyles, t.styles = this.styles, t.backgroundImages = this.backgroundImages, t.opacity = this.opacity }, r.prototype.getOpacity = function () { return null === this.opacity ? this.opacity = this.cssFloat("opacity") : this.opacity }, r.prototype.assignStack = function (t) { this.stack = t, t.children.push(this) }, r.prototype.isElementVisible = function () { return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : "none" !== this.css("display") && "hidden" !== this.css("visibility") && !this.node.hasAttribute("data-html2canvas-ignore") && ("INPUT" !== this.node.nodeName || "hidden" !== this.node.getAttribute("type")) }, r.prototype.css = function (t) { return this.computedStyles || (this.computedStyles = this.isPseudoElement ? this.parent.computedStyle(this.before ? ":before" : ":after") : this.computedStyle(null)), this.styles[t] || (this.styles[t] = this.computedStyles[t]) }, r.prototype.prefixedCss = function (t) { var e = ["webkit", "moz", "ms", "o"], n = this.css(t); return void 0 === n && e.some(function (e) { return n = this.css(e + t.substr(0, 1).toUpperCase() + t.substr(1)), void 0 !== n }, this), void 0 === n ? null : n }, r.prototype.computedStyle = function (t) { return this.node.ownerDocument.defaultView.getComputedStyle(this.node, t) }, r.prototype.cssInt = function (t) { var e = parseInt(this.css(t), 10); return isNaN(e) ? 0 : e }, r.prototype.color = function (t) { return this.colors[t] || (this.colors[t] = new l(this.css(t))) }, r.prototype.cssFloat = function (t) { var e = parseFloat(this.css(t)); return isNaN(e) ? 0 : e }, r.prototype.fontWeight = function () { var t = this.css("fontWeight"); switch (parseInt(t, 10)) { case 401: t = "bold"; break; case 400: t = "normal" } return t }, r.prototype.parseClip = function () { var t = this.css("clip").match(this.CLIP); return t ? { top: parseInt(t[1], 10), right: parseInt(t[2], 10), bottom: parseInt(t[3], 10), left: parseInt(t[4], 10) } : null }, r.prototype.parseBackgroundImages = function () { return this.backgroundImages || (this.backgroundImages = f(this.css("backgroundImage"))) }, r.prototype.cssList = function (t, e) { var n = (this.css(t) || "").split(","); return n = n[e || 0] || n[0] || "auto", n = n.trim().split(" "), 1 === n.length && (n = [n[0], a(n[0]) ? "auto" : n[0]]), n }, r.prototype.parseBackgroundSize = function (t, e, n) { var r, i, o = this.cssList("backgroundSize", n); if (a(o[0])) r = t.width * parseFloat(o[0]) / 100; else { if (/contain|cover/.test(o[0])) { var s = t.width / t.height, c = e.width / e.height; return s < c ^ "contain" === o[0] ? { width: t.height * c, height: t.height } : { width: t.width, height: t.width / c } } r = parseInt(o[0], 10) } return i = "auto" === o[0] && "auto" === o[1] ? e.height : "auto" === o[1] ? r / e.width * e.height : a(o[1]) ? t.height * parseFloat(o[1]) / 100 : parseInt(o[1], 10), "auto" === o[0] && (r = i / e.height * e.width), { width: r, height: i } }, r.prototype.parseBackgroundPosition = function (t, e, n, r) { var i, o, s = this.cssList("backgroundPosition", n); return i = a(s[0]) ? (t.width - (r || e).width) * (parseFloat(s[0]) / 100) : parseInt(s[0], 10), o = "auto" === s[1] ? i / e.width * e.height : a(s[1]) ? (t.height - (r || e).height) * parseFloat(s[1]) / 100 : parseInt(s[1], 10), "auto" === s[0] && (i = o / e.height * e.width), { left: i, top: o } }, r.prototype.parseBackgroundRepeat = function (t) { return this.cssList("backgroundRepeat", t)[0] }, r.prototype.parseTextShadows = function () { var t = this.css("textShadow"), e = []; if (t && "none" !== t) for (var n = t.match(this.TEXT_SHADOW_PROPERTY), r = 0; n && r < n.length; r++) { var i = n[r].match(this.TEXT_SHADOW_VALUES); e.push({ color: new l(i[0]), offsetX: i[1] ? parseFloat(i[1].replace("px", "")) : 0, offsetY: i[2] ? parseFloat(i[2].replace("px", "")) : 0, blur: i[3] ? i[3].replace("px", "") : 0 }) } return e }, r.prototype.parseTransform = function () { if (!this.transformData) if (this.hasTransform()) { var t = this.parseBounds(), e = this.prefixedCss("transformOrigin").split(" ").map(s).map(c); e[0] += t.left, e[1] += t.top, this.transformData = { origin: e, matrix: this.parseTransformMatrix() } } else this.transformData = { origin: [0, 0], matrix: [1, 0, 0, 1, 0, 0] }; return this.transformData }, r.prototype.parseTransformMatrix = function () { if (!this.transformMatrix) { var t = this.prefixedCss("transform"), e = t ? o(t.match(this.MATRIX_PROPERTY)) : null; this.transformMatrix = e ? e : [1, 0, 0, 1, 0, 0] } return this.transformMatrix }, r.prototype.parseBounds = function () { return this.bounds || (this.bounds = this.hasTransform() ? d(this.node) : h(this.node)) }, r.prototype.hasTransform = function () { return "1,0,0,1,0,0" !== this.parseTransformMatrix().join(",") || this.parent && this.parent.hasTransform() }, r.prototype.getValue = function () { var t = this.node.value || ""; return "SELECT" === this.node.tagName ? t = i(this.node) : "password" === this.node.type && (t = Array(t.length + 1).join("•")), 0 === t.length ? this.node.placeholder || "" : t }, r.prototype.MATRIX_PROPERTY = /(matrix|matrix3d)\((.+)\)/, r.prototype.TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g, r.prototype.TEXT_SHADOW_VALUES = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g, r.prototype.CLIP = /^rect\((\d+)px,? (\d+)px,? (\d+)px,? (\d+)px\)$/, e.exports = r }, { "./color": 3, "./utils": 26 }], 15: [function (t, e, n) {
function r(t, e, n, r, i) { L("Starting NodeParser"), this.renderer = e, this.options = i, this.range = null, this.support = n, this.renderQueue = [], this.stack = new Y(!0, 1, t.ownerDocument, null); var o = new U(t, null); if (i.background && e.rectangle(0, 0, e.width, e.height, new V(i.background)), t === t.ownerDocument.documentElement) { var a = new U(o.color("backgroundColor").isTransparent() ? t.ownerDocument.body : t.ownerDocument.documentElement, null); e.rectangle(0, 0, e.width, e.height, a.color("backgroundColor")) } o.visibile = o.isElementVisible(), this.createPseudoHideStyles(t.ownerDocument), this.disableAnimations(t.ownerDocument), this.nodes = B([o].concat(this.getChildren(o)).filter(function (t) { return t.visible = t.isElementVisible() }).map(this.getPseudoElements, this)), this.fontMetrics = new X, L("Fetched nodes, total:", this.nodes.length), L("Calculate overflow clips"), this.calculateOverflowClips(), L("Start fetching images"), this.images = r.fetch(this.nodes.filter(q)), this.ready = this.images.ready.then(J(function () { return L("Images loaded, starting parsing"), L("Creating stacking contexts"), this.createStackingContexts(), L("Sorting stacking contexts"), this.sortStackingContexts(this.stack), this.parse(this.stack), L("Render queue created with " + this.renderQueue.length + " items"), new Promise(J(function (t) { i.async ? "function" == typeof i.async ? i.async.call(this, this.renderQueue, t) : this.renderQueue.length > 0 ? (this.renderIndex = 0, this.asyncRenderer(this.renderQueue, t)) : t() : (this.renderQueue.forEach(this.paint, this), t()) }, this)) }, this)) } function i(t) { return t.parent && t.parent.clip.length } function o(t) { return t.replace(/(\-[a-z])/g, function (t) { return t.toUpperCase().replace("-", "") }) } function a() { } function s(t, e, n, r) { return t.map(function (i, o) { if (i.width > 0) { var a = e.left, s = e.top, c = e.width, l = e.height - t[2].width; switch (o) { case 0: l = t[0].width, i.args = h({ c1: [a, s], c2: [a + c, s], c3: [a + c - t[1].width, s + l], c4: [a + t[3].width, s + l] }, r[0], r[1], n.topLeftOuter, n.topLeftInner, n.topRightOuter, n.topRightInner); break; case 1: a = e.left + e.width - t[1].width, c = t[1].width, i.args = h({ c1: [a + c, s], c2: [a + c, s + l + t[2].width], c3: [a, s + l], c4: [a, s + t[0].width] }, r[1], r[2], n.topRightOuter, n.topRightInner, n.bottomRightOuter, n.bottomRightInner); break; case 2: s = s + e.height - t[2].width, l = t[2].width, i.args = h({ c1: [a + c, s + l], c2: [a, s + l], c3: [a + t[3].width, s], c4: [a + c - t[3].width, s] }, r[2], r[3], n.bottomRightOuter, n.bottomRightInner, n.bottomLeftOuter, n.bottomLeftInner); break; case 3: c = t[3].width, i.args = h({ c1: [a, s + l + t[2].width], c2: [a, s], c3: [a + c, s + t[0].width], c4: [a + c, s + l] }, r[3], r[0], n.bottomLeftOuter, n.bottomLeftInner, n.topLeftOuter, n.topLeftInner) } } return i }) } function c(t, e, n, r) { var i = 4 * ((Math.sqrt(2) - 1) / 3), o = n * i, a = r * i, s = t + n, c = e + r; return { topLeft: u({ x: t, y: c }, { x: t, y: c - a }, { x: s - o, y: e }, { x: s, y: e }), topRight: u({ x: t, y: e }, { x: t + o, y: e }, { x: s, y: c - a }, { x: s, y: c }), bottomRight: u({ x: s, y: e }, { x: s, y: e + a }, { x: t + o, y: c }, { x: t, y: c }), bottomLeft: u({ x: s, y: c }, { x: s - o, y: c }, { x: t, y: e + a }, { x: t, y: e }) } } function l(t, e, n) {
var r = t.left, i = t.top, o = t.width, a = t.height, s = e[0][0] < o / 2 ? e[0][0] : o / 2, l = e[0][1] < a / 2 ? e[0][1] : a / 2, u = e[1][0] < o / 2 ? e[1][0] : o / 2, h = e[1][1] < a / 2 ? e[1][1] : a / 2, f = e[2][0] < o / 2 ? e[2][0] : o / 2, d = e[2][1] < a / 2 ? e[2][1] : a / 2, p = e[3][0] < o / 2 ? e[3][0] : o / 2, g = e[3][1] < a / 2 ? e[3][1] : a / 2, m = o - u, w = a - d, y = o - f, v = a - g; return {
topLeftOuter: c(r, i, s, l).topLeft.subdivide(.5), topLeftInner: c(r + n[3].width, i + n[0].width, Math.max(0, s - n[3].width), Math.max(0, l - n[0].width)).topLeft.subdivide(.5), topRightOuter: c(r + m, i, u, h).topRight.subdivide(.5), topRightInner: c(r + Math.min(m, o + n[3].width), i + n[0].width, m > o + n[3].width ? 0 : u - n[3].width, h - n[0].width).topRight.subdivide(.5), bottomRightOuter: c(r + y, i + w, f, d).bottomRight.subdivide(.5), bottomRightInner: c(r + Math.min(y, o - n[3].width), i + Math.min(w, a + n[0].width), Math.max(0, f - n[1].width), d - n[2].width).bottomRight.subdivide(.5), bottomLeftOuter: c(r, i + v, p, g).bottomLeft.subdivide(.5),
bottomLeftInner: c(r + n[3].width, i + v, Math.max(0, p - n[3].width), g - n[2].width).bottomLeft.subdivide(.5)
}
} function u(t, e, n, r) { var i = function (t, e, n) { return { x: t.x + (e.x - t.x) * n, y: t.y + (e.y - t.y) * n } }; return { start: t, startControl: e, endControl: n, end: r, subdivide: function (o) { var a = i(t, e, o), s = i(e, n, o), c = i(n, r, o), l = i(a, s, o), h = i(s, c, o), f = i(l, h, o); return [u(t, a, l, f), u(f, h, c, r)] }, curveTo: function (t) { t.push(["bezierCurve", e.x, e.y, n.x, n.y, r.x, r.y]) }, curveToReversed: function (r) { r.push(["bezierCurve", n.x, n.y, e.x, e.y, t.x, t.y]) } } } function h(t, e, n, r, i, o, a) { var s = []; return e[0] > 0 || e[1] > 0 ? (s.push(["line", r[1].start.x, r[1].start.y]), r[1].curveTo(s)) : s.push(["line", t.c1[0], t.c1[1]]), n[0] > 0 || n[1] > 0 ? (s.push(["line", o[0].start.x, o[0].start.y]), o[0].curveTo(s), s.push(["line", a[0].end.x, a[0].end.y]), a[0].curveToReversed(s)) : (s.push(["line", t.c2[0], t.c2[1]]), s.push(["line", t.c3[0], t.c3[1]])), e[0] > 0 || e[1] > 0 ? (s.push(["line", i[1].end.x, i[1].end.y]), i[1].curveToReversed(s)) : s.push(["line", t.c4[0], t.c4[1]]), s } function f(t, e, n, r, i, o, a) { e[0] > 0 || e[1] > 0 ? (t.push(["line", r[0].start.x, r[0].start.y]), r[0].curveTo(t), r[1].curveTo(t)) : t.push(["line", o, a]), (n[0] > 0 || n[1] > 0) && t.push(["line", i[0].start.x, i[0].start.y]) } function d(t) { return t.cssInt("zIndex") < 0 } function p(t) { return t.cssInt("zIndex") > 0 } function g(t) { return 0 === t.cssInt("zIndex") } function m(t) { return ["inline", "inline-block", "inline-table"].indexOf(t.css("display")) !== -1 } function w(t) { return t instanceof Y } function y(t) { return t.node.data.trim().length > 0 } function v(t) { return /^(normal|none|0px)$/.test(t.parent.css("letterSpacing")) } function b(t) { return ["TopLeft", "TopRight", "BottomRight", "BottomLeft"].map(function (e) { var n = t.css("border" + e + "Radius"), r = n.split(" "); return r.length <= 1 && (r[1] = r[0]), r.map(O) }) } function x(t) { return t.nodeType === Node.TEXT_NODE || t.nodeType === Node.ELEMENT_NODE } function k(t) { var e = t.css("position"), n = ["absolute", "relative", "fixed"].indexOf(e) !== -1 ? t.css("zIndex") : "auto"; return "auto" !== n } function _(t) { return "static" !== t.css("position") } function C(t) { return "none" !== t.css("float") } function A(t) { return ["inline-block", "inline-table"].indexOf(t.css("display")) !== -1 } function S(t) { var e = this; return function () { return !t.apply(e, arguments) } } function q(t) { return t.node.nodeType === Node.ELEMENT_NODE } function T(t) { return t.isPseudoElement === !0 } function P(t) { return t.node.nodeType === Node.TEXT_NODE } function I(t) { return function (e, n) { return e.cssInt("zIndex") + t.indexOf(e) / t.length - (n.cssInt("zIndex") + t.indexOf(n) / t.length) } } function E(t) { return t.getOpacity() < 1 } function O(t) { return parseInt(t, 10) } function F(t) { return t.width } function R(t) { return t.node.nodeType !== Node.ELEMENT_NODE || ["SCRIPT", "HEAD", "TITLE", "OBJECT", "BR", "OPTION"].indexOf(t.node.nodeName) === -1 } function B(t) { return [].concat.apply([], t) } function D(t) { var e = t.substr(0, 1); return e === t.substr(t.length - 1) && e.match(/'|"/) ? t.substr(1, t.length - 2) : t } function j(t) { for (var e, n = [], r = 0, i = !1; t.length;) z(t[r]) === i ? (e = t.splice(0, r), e.length && n.push(M.ucs2.encode(e)), i = !i, r = 0) : r++, r >= t.length && (e = t.splice(0, r), e.length && n.push(M.ucs2.encode(e))); return n } function z(t) { return [32, 13, 10, 9, 45].indexOf(t) !== -1 } function N(t) { return /[^\u0000-\u00ff]/.test(t) } var L = t("./log"), M = t("punycode"), U = t("./nodecontainer"), H = t("./textcontainer"), W = t("./pseudoelementcontainer"), X = t("./fontmetrics"), V = t("./color"), Y = t("./stackingcontext"), G = t("./utils"), J = G.bind, Q = G.getBounds, K = G.parseBackgrounds, $ = G.offsetBounds; r.prototype.calculateOverflowClips = function () { this.nodes.forEach(function (t) { if (q(t)) { T(t) && t.appendToDOM(), t.borders = this.parseBorders(t); var e = "hidden" === t.css("overflow") ? [t.borders.clip] : [], n = t.parseClip(); n && ["absolute", "fixed"].indexOf(t.css("position")) !== -1 && e.push([["rect", t.bounds.left + n.left, t.bounds.top + n.top, n.right - n.left, n.bottom - n.top]]), t.clip = i(t) ? t.parent.clip.concat(e) : e, t.backgroundClip = "hidden" !== t.css("overflow") ? t.clip.concat([t.borders.clip]) : t.clip, T(t) && t.cleanDOM() } else P(t) && (t.clip = i(t) ? t.parent.clip : []); T(t) || (t.bounds = null) }, this) }, r.prototype.asyncRenderer = function (t, e, n) { n = n || Date.now(), this.paint(t[this.renderIndex++]), t.length === this.renderIndex ? e() : n + 20 > Date.now() ? this.asyncRenderer(t, e, n) : setTimeout(J(function () { this.asyncRenderer(t, e) }, this), 0) }, r.prototype.createPseudoHideStyles = function (t) { this.createStyles(t, "." + W.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + ':before { content: "" !important; display: none !important; }.' + W.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER + ':after { content: "" !important; display: none !important; }') }, r.prototype.disableAnimations = function (t) { this.createStyles(t, "* { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; animation: none !important; -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; transition: none !important;}") }, r.prototype.createStyles = function (t, e) { var n = t.createElement("style"); n.innerHTML = e, t.body.appendChild(n) }, r.prototype.getPseudoElements = function (t) { var e = [[t]]; if (t.node.nodeType === Node.ELEMENT_NODE) { var n = this.getPseudoElement(t, ":before"), r = this.getPseudoElement(t, ":after"); n && e.push(n), r && e.push(r) } return B(e) }, r.prototype.getPseudoElement = function (t, e) { var n = t.computedStyle(e); if (!n || !n.content || "none" === n.content || "-moz-alt-content" === n.content || "none" === n.display) return null; for (var r = D(n.content), i = "url" === r.substr(0, 3), a = document.createElement(i ? "img" : "html2canvaspseudoelement"), s = new W(a, t, e), c = n.length - 1; c >= 0; c--) { var l = o(n.item(c)); a.style[l] = n[l] } if (a.className = W.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + W.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER, i) return a.src = K(r)[0].args[0], [s]; var u = document.createTextNode(r); return a.appendChild(u), [s, new H(u, s)] }, r.prototype.getChildren = function (t) { return B([].filter.call(t.node.childNodes, x).map(function (e) { var n = [e.nodeType === Node.TEXT_NODE ? new H(e, t) : new U(e, t)].filter(R); return e.nodeType === Node.ELEMENT_NODE && n.length && "TEXTAREA" !== e.tagName ? n[0].isElementVisible() ? n.concat(this.getChildren(n[0])) : [] : n }, this)) }, r.prototype.newStackingContext = function (t, e) { var n = new Y(e, t.getOpacity(), t.node, t.parent); t.cloneTo(n); var r = e ? n.getParentStack(this) : n.parent.stack; r.contexts.push(n), t.stack = n }, r.prototype.createStackingContexts = function () { this.nodes.forEach(function (t) { q(t) && (this.isRootElement(t) || E(t) || k(t) || this.isBodyWithTransparentRoot(t) || t.hasTransform()) ? this.newStackingContext(t, !0) : q(t) && (_(t) && g(t) || A(t) || C(t)) ? this.newStackingContext(t, !1) : t.assignStack(t.parent.stack) }, this) }, r.prototype.isBodyWithTransparentRoot = function (t) { return "BODY" === t.node.nodeName && t.parent.color("backgroundColor").isTransparent() }, r.prototype.isRootElement = function (t) { return null === t.parent }, r.prototype.sortStackingContexts = function (t) { t.contexts.sort(I(t.contexts.slice(0))), t.contexts.forEach(this.sortStackingContexts, this) }, r.prototype.parseTextBounds = function (t) { return function (e, n, r) { if ("none" !== t.parent.css("textDecoration").substr(0, 4) || 0 !== e.trim().length) { if (this.support.rangeBounds && !t.parent.hasTransform()) { var i = r.slice(0, n).join("").length; return this.getRangeBounds(t.node, i, e.length) } if (t.node && "string" == typeof t.node.data) { var o = t.node.splitText(e.length), a = this.getWrapperBounds(t.node, t.parent.hasTransform()); return t.node = o, a } } else this.support.rangeBounds && !t.parent.hasTransform() || (t.node = t.node.splitText(e.length)); return {} } }, r.prototype.getWrapperBounds = function (t, e) { var n = t.ownerDocument.createElement("html2canvaswrapper"), r = t.parentNode, i = t.cloneNode(!0); n.appendChild(t.cloneNode(!0)), r.replaceChild(n, t); var o = e ? $(n) : Q(n); return r.replaceChild(i, n), o }, r.prototype.getRangeBounds = function (t, e, n) { var r = this.range || (this.range = t.ownerDocument.createRange()); return r.setStart(t, e), r.setEnd(t, e + n), r.getBoundingClientRect() }, r.prototype.parse = function (t) { var e = t.contexts.filter(d), n = t.children.filter(q), r = n.filter(S(C)), i = r.filter(S(_)).filter(S(m)), o = n.filter(S(_)).filter(C), s = r.filter(S(_)).filter(m), c = t.contexts.concat(r.filter(_)).filter(g), l = t.children.filter(P).filter(y), u = t.contexts.filter(p); e.concat(i).concat(o).concat(s).concat(c).concat(l).concat(u).forEach(function (t) { this.renderQueue.push(t), w(t) && (this.parse(t), this.renderQueue.push(new a)) }, this) }, r.prototype.paint = function (t) { try { t instanceof a ? this.renderer.ctx.restore() : P(t) ? (T(t.parent) && t.parent.appendToDOM(), this.paintText(t), T(t.parent) && t.parent.cleanDOM()) : this.paintNode(t) } catch (t) { if (L(t), this.options.strict) throw t } }, r.prototype.paintNode = function (t) { w(t) && (this.renderer.setOpacity(t.opacity), this.renderer.ctx.save(), t.hasTransform() && this.renderer.setTransform(t.parseTransform())), "INPUT" === t.node.nodeName && "checkbox" === t.node.type ? this.paintCheckbox(t) : "INPUT" === t.node.nodeName && "radio" === t.node.type ? this.paintRadio(t) : this.paintElement(t) }, r.prototype.paintElement = function (t) { var e = t.parseBounds(); this.renderer.clip(t.backgroundClip, function () { this.renderer.renderBackground(t, e, t.borders.borders.map(F)) }, this), this.renderer.clip(t.clip, function () { this.renderer.renderBorders(t.borders.borders) }, this), this.renderer.clip(t.backgroundClip, function () { switch (t.node.nodeName) { case "svg": case "IFRAME": var n = this.images.get(t.node); n ? this.renderer.renderImage(t, e, t.borders, n) : L("Error loading <" + t.node.nodeName + ">", t.node); break; case "IMG": var r = this.images.get(t.node.src); r ? this.renderer.renderImage(t, e, t.borders, r) : L("Error loading
", t.node.src); break; case "CANVAS": this.renderer.renderImage(t, e, t.borders, { image: t.node }); break; case "SELECT": case "INPUT": case "TEXTAREA": this.paintFormValue(t) } }, this) }, r.prototype.paintCheckbox = function (t) { var e = t.parseBounds(), n = Math.min(e.width, e.height), r = { width: n - 1, height: n - 1, top: e.top, left: e.left }, i = [3, 3], o = [i, i, i, i], a = [1, 1, 1, 1].map(function (t) { return { color: new V("#A5A5A5"), width: t } }), c = l(r, o, a); this.renderer.clip(t.backgroundClip, function () { this.renderer.rectangle(r.left + 1, r.top + 1, r.width - 2, r.height - 2, new V("#DEDEDE")), this.renderer.renderBorders(s(a, r, c, o)), t.node.checked && (this.renderer.font(new V("#424242"), "normal", "normal", "bold", n - 3 + "px", "arial"), this.renderer.text("?", r.left + n / 6, r.top + n - 1)) }, this) }, r.prototype.paintRadio = function (t) { var e = t.parseBounds(), n = Math.min(e.width, e.height) - 2; this.renderer.clip(t.backgroundClip, function () { this.renderer.circleStroke(e.left + 1, e.top + 1, n, new V("#DEDEDE"), 1, new V("#A5A5A5")), t.node.checked && this.renderer.circle(Math.ceil(e.left + n / 4) + 1, Math.ceil(e.top + n / 4) + 1, Math.floor(n / 2), new V("#424242")) }, this) }, r.prototype.paintFormValue = function (t) { var e = t.getValue(); if (e.length > 0) { var n = t.node.ownerDocument, r = n.createElement("html2canvaswrapper"), i = ["lineHeight", "textAlign", "fontFamily", "fontWeight", "fontSize", "color", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom", "width", "height", "borderLeftStyle", "borderTopStyle", "borderLeftWidth", "borderTopWidth", "boxSizing", "whiteSpace", "wordWrap"]; i.forEach(function (e) { try { r.style[e] = t.css(e) } catch (t) { L("html2canvas: Parse: Exception caught in renderFormValue: " + t.message) } }); var o = t.parseBounds(); r.style.position = "fixed", r.style.left = o.left + "px", r.style.top = o.top + "px", r.textContent = e, n.body.appendChild(r), this.paintText(new H(r.firstChild, t)), n.body.removeChild(r) } }, r.prototype.paintText = function (t) { t.applyTextTransform(); var e = M.ucs2.decode(t.node.data), n = this.options.letterRendering && !v(t) || N(t.node.data) ? e.map(function (t) { return M.ucs2.encode([t]) }) : j(e), r = t.parent.fontWeight(), i = t.parent.css("fontSize"), o = t.parent.css("fontFamily"), a = t.parent.parseTextShadows(); this.renderer.font(t.parent.color("color"), t.parent.css("fontStyle"), t.parent.css("fontVariant"), r, i, o), a.length ? this.renderer.fontShadow(a[0].color, a[0].offsetX, a[0].offsetY, a[0].blur) : this.renderer.clearShadow(), this.renderer.clip(t.parent.clip, function () { n.map(this.parseTextBounds(t), this).forEach(function (e, r) { e && (this.renderer.text(n[r], e.left, e.bottom), this.renderTextDecoration(t.parent, e, this.fontMetrics.getMetrics(o, i))) }, this) }, this) }, r.prototype.renderTextDecoration = function (t, e, n) { switch (t.css("textDecoration").split(" ")[0]) { case "underline": this.renderer.rectangle(e.left, Math.round(e.top + n.baseline + n.lineWidth), e.width, 1, t.color("color")); break; case "overline": this.renderer.rectangle(e.left, Math.round(e.top), e.width, 1, t.color("color")); break; case "line-through": this.renderer.rectangle(e.left, Math.ceil(e.top + n.middle + n.lineWidth), e.width, 1, t.color("color")) } }; var Z = { inset: [["darken", .6], ["darken", .1], ["darken", .1], ["darken", .6]] }; r.prototype.parseBorders = function (t) { var e = t.parseBounds(), n = b(t), r = ["Top", "Right", "Bottom", "Left"].map(function (e, n) { var r = t.css("border" + e + "Style"), i = t.color("border" + e + "Color"); "inset" === r && i.isBlack() && (i = new V([255, 255, 255, i.a])); var o = Z[r] ? Z[r][n] : null; return { width: t.cssInt("border" + e + "Width"), color: o ? i[o[0]](o[1]) : i, args: null } }), i = l(e, n, r); return { clip: this.parseBackgroundClip(t, i, r, n, e), borders: s(r, e, i, n) } }, r.prototype.parseBackgroundClip = function (t, e, n, r, i) { var o = t.css("backgroundClip"), a = []; switch (o) { case "content-box": case "padding-box": f(a, r[0], r[1], e.topLeftInner, e.topRightInner, i.left + n[3].width, i.top + n[0].width), f(a, r[1], r[2], e.topRightInner, e.bottomRightInner, i.left + i.width - n[1].width, i.top + n[0].width), f(a, r[2], r[3], e.bottomRightInner, e.bottomLeftInner, i.left + i.width - n[1].width, i.top + i.height - n[2].width), f(a, r[3], r[0], e.bottomLeftInner, e.topLeftInner, i.left + n[3].width, i.top + i.height - n[2].width); break; default: f(a, r[0], r[1], e.topLeftOuter, e.topRightOuter, i.left, i.top), f(a, r[1], r[2], e.topRightOuter, e.bottomRightOuter, i.left + i.width, i.top), f(a, r[2], r[3], e.bottomRightOuter, e.bottomLeftOuter, i.left + i.width, i.top + i.height), f(a, r[3], r[0], e.bottomLeftOuter, e.topLeftOuter, i.left, i.top + i.height) } return a }, e.exports = r
}, { "./color": 3, "./fontmetrics": 7, "./log": 13, "./nodecontainer": 14, "./pseudoelementcontainer": 18, "./stackingcontext": 21, "./textcontainer": 25, "./utils": 26, punycode: 1 }], 16: [function (t, e, n) { function r(t, e, n) { var r = "withCredentials" in new XMLHttpRequest; if (!e) return Promise.reject("No proxy configured"); var i = a(r), c = s(e, t, i); return r ? u(c) : o(n, c, i).then(function (t) { return p(t.content) }) } function i(t, e, n) { var r = "crossOrigin" in new Image, i = a(r), c = s(e, t, i); return r ? Promise.resolve(c) : o(n, c, i).then(function (t) { return "data:" + t.type + ";base64," + t.content }) } function o(t, e, n) { return new Promise(function (r, i) { var o = t.createElement("script"), a = function () { delete window.html2canvas.proxy[n], t.body.removeChild(o) }; window.html2canvas.proxy[n] = function (t) { a(), r(t) }, o.src = e, o.onerror = function (t) { a(), i(t) }, t.body.appendChild(o) }) } function a(t) { return t ? "" : "html2canvas_" + Date.now() + "_" + ++g + "_" + Math.round(1e5 * Math.random()) } function s(t, e, n) { return t + "?url=" + encodeURIComponent(e) + (n.length ? "&callback=html2canvas.proxy." + n : "") } function c(t) { return function (e) { var n, r = new DOMParser; try { n = r.parseFromString(e, "text/html") } catch (t) { f("DOMParser not supported, falling back to createHTMLDocument"), n = document.implementation.createHTMLDocument(""); try { n.open(), n.write(e), n.close() } catch (t) { f("createHTMLDocument write not supported, falling back to document.body.innerHTML"), n.body.innerHTML = e } } var i = n.querySelector("base"); if (!i || !i.href.host) { var o = n.createElement("base"); o.href = t, n.head.insertBefore(o, n.head.firstChild) } return n } } function l(t, e, n, i, o, a) { return new r(t, e, window.document).then(c(t)).then(function (t) { return d(t, n, i, o, a, 0, 0) }) } var u = t("./xhr"), h = t("./utils"), f = t("./log"), d = t("./clone"), p = h.decode64, g = 0; n.Proxy = r, n.ProxyURL = i, n.loadUrlDocument = l }, { "./clone": 2, "./log": 13, "./utils": 26, "./xhr": 28 }], 17: [function (t, e, n) { function r(t, e) { var n = document.createElement("a"); n.href = t, t = n.href, this.src = t, this.image = new Image; var r = this; this.promise = new Promise(function (n, o) { r.image.crossOrigin = "Anonymous", r.image.onload = n, r.image.onerror = o, new i(t, e, document).then(function (t) { r.image.src = t }).catch(o) }) } var i = t("./proxy").ProxyURL; e.exports = r }, { "./proxy": 16 }], 18: [function (t, e, n) { function r(t, e, n) { i.call(this, t, e), this.isPseudoElement = !0, this.before = ":before" === n } var i = t("./nodecontainer"); r.prototype.cloneTo = function (t) { r.prototype.cloneTo.call(this, t), t.isPseudoElement = !0, t.before = this.before }, r.prototype = Object.create(i.prototype), r.prototype.appendToDOM = function () { this.before ? this.parent.node.insertBefore(this.node, this.parent.node.firstChild) : this.parent.node.appendChild(this.node), this.parent.node.className += " " + this.getHideClass() }, r.prototype.cleanDOM = function () { this.node.parentNode.removeChild(this.node), this.parent.node.className = this.parent.node.className.replace(this.getHideClass(), "") }, r.prototype.getHideClass = function () { return this["PSEUDO_HIDE_ELEMENT_CLASS_" + (this.before ? "BEFORE" : "AFTER")] }, r.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before", r.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after", e.exports = r }, { "./nodecontainer": 14 }], 19: [function (t, e, n) { function r(t, e, n, r, i) { this.width = t, this.height = e, this.images = n, this.options = r, this.document = i } var i = t("./log"); r.prototype.renderImage = function (t, e, n, r) { var i = t.cssInt("paddingLeft"), o = t.cssInt("paddingTop"), a = t.cssInt("paddingRight"), s = t.cssInt("paddingBottom"), c = n.borders, l = e.width - (c[1].width + c[3].width + i + a), u = e.height - (c[0].width + c[2].width + o + s); this.drawImage(r, 0, 0, r.image.width || l, r.image.height || u, e.left + i + c[3].width, e.top + o + c[0].width, l, u) }, r.prototype.renderBackground = function (t, e, n) { e.height > 0 && e.width > 0 && (this.renderBackgroundColor(t, e), this.renderBackgroundImage(t, e, n)) }, r.prototype.renderBackgroundColor = function (t, e) { var n = t.color("backgroundColor"); n.isTransparent() || this.rectangle(e.left, e.top, e.width, e.height, n) }, r.prototype.renderBorders = function (t) { t.forEach(this.renderBorder, this) }, r.prototype.renderBorder = function (t) { t.color.isTransparent() || null === t.args || this.drawShape(t.args, t.color) }, r.prototype.renderBackgroundImage = function (t, e, n) { var r = t.parseBackgroundImages(); r.reverse().forEach(function (r, o, a) { switch (r.method) { case "url": var s = this.images.get(r.args[0]); s ? this.renderBackgroundRepeating(t, e, s, a.length - (o + 1), n) : i("Error loading background-image", r.args[0]); break; case "linear-gradient": case "gradient": var c = this.images.get(r.value); c ? this.renderBackgroundGradient(c, e, n) : i("Error loading background-image", r.args[0]); break; case "none": break; default: i("Unknown background-image type", r.args[0]) } }, this) }, r.prototype.renderBackgroundRepeating = function (t, e, n, r, i) { var o = t.parseBackgroundSize(e, n.image, r), a = t.parseBackgroundPosition(e, n.image, r, o), s = t.parseBackgroundRepeat(r); switch (s) { case "repeat-x": case "repeat no-repeat": this.backgroundRepeatShape(n, a, o, e, e.left + i[3], e.top + a.top + i[0], 99999, o.height, i); break; case "repeat-y": case "no-repeat repeat": this.backgroundRepeatShape(n, a, o, e, e.left + a.left + i[3], e.top + i[0], o.width, 99999, i); break; case "no-repeat": this.backgroundRepeatShape(n, a, o, e, e.left + a.left + i[3], e.top + a.top + i[0], o.width, o.height, i); break; default: this.renderBackgroundRepeat(n, a, o, { top: e.top, left: e.left }, i[3], i[0]) } }, e.exports = r }, { "./log": 13 }], 20: [function (t, e, n) { function r(t, e) { o.apply(this, arguments), this.canvas = this.options.canvas || this.document.createElement("canvas"), this.options.canvas || (this.canvas.width = t, this.canvas.height = e), this.ctx = this.canvas.getContext("2d"), this.taintCtx = this.document.createElement("canvas").getContext("2d"), this.ctx.textBaseline = "bottom", this.variables = {}, s("Initialized CanvasRenderer with size", t, "x", e) } function i(t) { return t.length > 0 } var o = t("../renderer"), a = t("../lineargradientcontainer"), s = t("../log"); r.prototype = Object.create(o.prototype), r.prototype.setFillStyle = function (t) { return this.ctx.fillStyle = "object" == typeof t && t.isColor ? t.toString() : t, this.ctx }, r.prototype.rectangle = function (t, e, n, r, i) { this.setFillStyle(i).fillRect(t, e, n, r) }, r.prototype.circle = function (t, e, n, r) { this.setFillStyle(r), this.ctx.beginPath(), this.ctx.arc(t + n / 2, e + n / 2, n / 2, 0, 2 * Math.PI, !0), this.ctx.closePath(), this.ctx.fill() }, r.prototype.circleStroke = function (t, e, n, r, i, o) { this.circle(t, e, n, r), this.ctx.strokeStyle = o.toString(), this.ctx.stroke() }, r.prototype.drawShape = function (t, e) { this.shape(t), this.setFillStyle(e).fill() }, r.prototype.taints = function (t) { if (null === t.tainted) { this.taintCtx.drawImage(t.image, 0, 0); try { this.taintCtx.getImageData(0, 0, 1, 1), t.tainted = !1 } catch (e) { this.taintCtx = document.createElement("canvas").getContext("2d"), t.tainted = !0 } } return t.tainted }, r.prototype.drawImage = function (t, e, n, r, i, o, a, s, c) { this.taints(t) && !this.options.allowTaint || this.ctx.drawImage(t.image, e, n, r, i, o, a, s, c) }, r.prototype.clip = function (t, e, n) { this.ctx.save(), t.filter(i).forEach(function (t) { this.shape(t).clip() }, this), e.call(n), this.ctx.restore() }, r.prototype.shape = function (t) { return this.ctx.beginPath(), t.forEach(function (t, e) { "rect" === t[0] ? this.ctx.rect.apply(this.ctx, t.slice(1)) : this.ctx[0 === e ? "moveTo" : t[0] + "To"].apply(this.ctx, t.slice(1)) }, this), this.ctx.closePath(), this.ctx }, r.prototype.font = function (t, e, n, r, i, o) { this.setFillStyle(t).font = [e, n, r, i, o].join(" ").split(",")[0] }, r.prototype.fontShadow = function (t, e, n, r) { this.setVariable("shadowColor", t.toString()).setVariable("shadowOffsetY", e).setVariable("shadowOffsetX", n).setVariable("shadowBlur", r) }, r.prototype.clearShadow = function () { this.setVariable("shadowColor", "rgba(0,0,0,0)") }, r.prototype.setOpacity = function (t) { this.ctx.globalAlpha = t }, r.prototype.setTransform = function (t) { this.ctx.translate(t.origin[0], t.origin[1]), this.ctx.transform.apply(this.ctx, t.matrix), this.ctx.translate(-t.origin[0], -t.origin[1]) }, r.prototype.setVariable = function (t, e) { return this.variables[t] !== e && (this.variables[t] = this.ctx[t] = e), this }, r.prototype.text = function (t, e, n) { this.ctx.fillText(t, e, n) }, r.prototype.backgroundRepeatShape = function (t, e, n, r, i, o, a, s, c) { var l = [["line", Math.round(i), Math.round(o)], ["line", Math.round(i + a), Math.round(o)], ["line", Math.round(i + a), Math.round(s + o)], ["line", Math.round(i), Math.round(s + o)]]; this.clip([l], function () { this.renderBackgroundRepeat(t, e, n, r, c[3], c[0]) }, this) }, r.prototype.renderBackgroundRepeat = function (t, e, n, r, i, o) { var a = Math.round(r.left + e.left + i), s = Math.round(r.top + e.top + o); this.setFillStyle(this.ctx.createPattern(this.resizeImage(t, n), "repeat")), this.ctx.translate(a, s), this.ctx.fill(), this.ctx.translate(-a, -s) }, r.prototype.renderBackgroundGradient = function (t, e) { if (t instanceof a) { var n = this.ctx.createLinearGradient(e.left + e.width * t.x0, e.top + e.height * t.y0, e.left + e.width * t.x1, e.top + e.height * t.y1); t.colorStops.forEach(function (t) { n.addColorStop(t.stop, t.color.toString()) }), this.rectangle(e.left, e.top, e.width, e.height, n) } }, r.prototype.resizeImage = function (t, e) { var n = t.image; if (n.width === e.width && n.height === e.height) return n; var r, i = document.createElement("canvas"); return i.width = e.width, i.height = e.height, r = i.getContext("2d"), r.drawImage(n, 0, 0, n.width, n.height, 0, 0, e.width, e.height), i }, e.exports = r }, { "../lineargradientcontainer": 12, "../log": 13, "../renderer": 19 }], 21: [function (t, e, n) { function r(t, e, n, r) { i.call(this, n, r), this.ownStacking = t, this.contexts = [], this.children = [], this.opacity = (this.parent ? this.parent.stack.opacity : 1) * e } var i = t("./nodecontainer"); r.prototype = Object.create(i.prototype), r.prototype.getParentStack = function (t) { var e = this.parent ? this.parent.stack : null; return e ? e.ownStacking ? e : e.getParentStack(t) : t.stack }, e.exports = r }, { "./nodecontainer": 14 }], 22: [function (t, e, n) { function r(t) { this.rangeBounds = this.testRangeBounds(t), this.cors = this.testCORS(), this.svg = this.testSVG() } r.prototype.testRangeBounds = function (t) { var e, n, r, i, o = !1; return t.createRange && (e = t.createRange(), e.getBoundingClientRect && (n = t.createElement("boundtest"), n.style.height = "123px", n.style.display = "block", t.body.appendChild(n), e.selectNode(n), r = e.getBoundingClientRect(), i = r.height, 123 === i && (o = !0), t.body.removeChild(n))), o }, r.prototype.testCORS = function () { return "undefined" != typeof (new Image).crossOrigin }, r.prototype.testSVG = function () { var t = new Image, e = document.createElement("canvas"), n = e.getContext("2d"); t.src = "data:image/svg+xml,"; try { n.drawImage(t, 0, 0), e.toDataURL() } catch (t) { return !1 } return !0 }, e.exports = r }, {}], 23: [function (t, e, n) { function r(t) { this.src = t, this.image = null; var e = this; this.promise = this.hasFabric().then(function () { return e.isInline(t) ? Promise.resolve(e.inlineFormatting(t)) : i(t) }).then(function (t) { return new Promise(function (n) { window.html2canvas.svg.fabric.loadSVGFromString(t, e.createCanvas.call(e, n)) }) }) } var i = t("./xhr"), o = t("./utils").decode64; r.prototype.hasFabric = function () { return window.html2canvas.svg && window.html2canvas.svg.fabric ? Promise.resolve() : Promise.reject(new Error("html2canvas.svg.js is not loaded, cannot render svg")) }, r.prototype.inlineFormatting = function (t) { return /^data:image\/svg\+xml;base64,/.test(t) ? this.decode64(this.removeContentType(t)) : this.removeContentType(t) }, r.prototype.removeContentType = function (t) { return t.replace(/^data:image\/svg\+xml(;base64)?,/, "") }, r.prototype.isInline = function (t) { return /^data:image\/svg\+xml/i.test(t) }, r.prototype.createCanvas = function (t) { var e = this; return function (n, r) { var i = new window.html2canvas.svg.fabric.StaticCanvas("c"); e.image = i.lowerCanvasEl, i.setWidth(r.width).setHeight(r.height).add(window.html2canvas.svg.fabric.util.groupSVGElements(n, r)).renderAll(), t(i.lowerCanvasEl) } }, r.prototype.decode64 = function (t) { return "function" == typeof window.atob ? window.atob(t) : o(t) }, e.exports = r }, { "./utils": 26, "./xhr": 28 }], 24: [function (t, e, n) { function r(t, e) { this.src = t, this.image = null; var n = this; this.promise = e ? new Promise(function (e, r) { n.image = new Image, n.image.onload = e, n.image.onerror = r, n.image.src = "data:image/svg+xml," + (new XMLSerializer).serializeToString(t), n.image.complete === !0 && e(n.image) }) : this.hasFabric().then(function () { return new Promise(function (e) { window.html2canvas.svg.fabric.parseSVGDocument(t, n.createCanvas.call(n, e)) }) }) } var i = t("./svgcontainer"); r.prototype = Object.create(i.prototype), e.exports = r }, { "./svgcontainer": 23 }], 25: [function (t, e, n) { function r(t, e) { o.call(this, t, e) } function i(t, e, n) { if (t.length > 0) return e + n.toUpperCase() } var o = t("./nodecontainer"); r.prototype = Object.create(o.prototype), r.prototype.applyTextTransform = function () { this.node.data = this.transform(this.parent.css("textTransform")) }, r.prototype.transform = function (t) { var e = this.node.data; switch (t) { case "lowercase": return e.toLowerCase(); case "capitalize": return e.replace(/(^|\s|:|-|\(|\))([a-z])/g, i); case "uppercase": return e.toUpperCase(); default: return e } }, e.exports = r }, { "./nodecontainer": 14 }], 26: [function (t, e, n) {
n.smallImage = function () { return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" }, n.bind = function (t, e) { return function () { return t.apply(e, arguments) } },/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*/
n.decode64 = function (t) { var e, n, r, i, o, a, s, c, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\\index.html", u = t.length, h = ""; for (e = 0; e < u; e += 4) n = l.indexOf(t[e]), r = l.indexOf(t[e + 1]), i = l.indexOf(t[e + 2]), o = l.indexOf(t[e + 3]), a = n << 2 | r >> 4, s = (15 & r) << 4 | i >> 2, c = (3 & i) << 6 | o, h += 64 === i ? String.fromCharCode(a) : 64 === o || o === -1 ? String.fromCharCode(a, s) : String.fromCharCode(a, s, c); return h }, n.getBounds = function (t) { if (t.getBoundingClientRect) { var e = t.getBoundingClientRect(), n = null == t.offsetWidth ? e.width : t.offsetWidth; return { top: e.top, bottom: e.bottom || e.top + e.height, right: e.left + n, left: e.left, width: n, height: null == t.offsetHeight ? e.height : t.offsetHeight } } return {} }, n.offsetBounds = function (t) { var e = t.offsetParent ? n.offsetBounds(t.offsetParent) : { top: 0, left: 0 }; return { top: t.offsetTop + e.top, bottom: t.offsetTop + t.offsetHeight + e.top, right: t.offsetLeft + e.left + t.offsetWidth, left: t.offsetLeft + e.left, width: t.offsetWidth, height: t.offsetHeight } }, n.parseBackgrounds = function (t) { var e, n, r, i, o, a, s, c = " \r\n\t", l = [], u = 0, h = 0, f = function () { e && ('"' === n.substr(0, 1) && (n = n.substr(1, n.length - 2)), n && s.push(n), "-" === e.substr(0, 1) && (i = e.indexOf("-", 1) + 1) > 0 && (r = e.substr(0, i), e = e.substr(i)), l.push({ prefix: r, method: e.toLowerCase(), value: o, args: s, image: null })), s = [], e = r = n = o = "" }; return s = [], e = r = n = o = "", t.split("").forEach(function (t) { if (!(0 === u && c.indexOf(t) > -1)) { switch (t) { case '"': a ? a === t && (a = null) : a = t; break; case "(": if (a) break; if (0 === u) return u = 1, void (o += t); h++; break; case ")": if (a) break; if (1 === u) { if (0 === h) return u = 0, o += t, void f(); h-- } break; case ",": if (a) break; if (0 === u) return void f(); if (1 === u && 0 === h && !e.match(/^url$/i)) return s.push(n), n = "", void (o += t) } o += t, 0 === u ? e += t : n += t } }), f(), l }
}, {}], 27: [function (t, e, n) { function r(t) { i.apply(this, arguments), this.type = "linear" === t.args[0] ? i.TYPES.LINEAR : i.TYPES.RADIAL } var i = t("./gradientcontainer"); r.prototype = Object.create(i.prototype), e.exports = r }, { "./gradientcontainer": 9 }], 28: [function (t, e, n) { function r(t) { return new Promise(function (e, n) { var r = new XMLHttpRequest; r.open("GET", t), r.onload = function () { 200 === r.status ? e(r.responseText) : n(new Error(r.statusText)) }, r.onerror = function () { n(new Error("Network Error")) }, r.send() }) } e.exports = r }, {}]
}, {}, [4])(4)
}),/*
# PNG.js
# Copyright (c) 2011 Devon Govett
# MIT LICENSE
#
#
*/
function (t) { var e; e = function () { function e(t) { var e, n, r, i, o, a, s, c, l, u, h, f, d, p, g; for (this.data = t, this.pos = 8, this.palette = [], this.imgData = [], this.transparency = {}, this.animation = null, this.text = {}, a = null; ;) { switch (e = this.readUInt32(), u = function () { var t, e; for (e = [], s = t = 0; t < 4; s = ++t) e.push(String.fromCharCode(this.data[this.pos++])); return e }.call(this).join("")) { case "IHDR": this.width = this.readUInt32(), this.height = this.readUInt32(), this.bits = this.data[this.pos++], this.colorType = this.data[this.pos++], this.compressionMethod = this.data[this.pos++], this.filterMethod = this.data[this.pos++], this.interlaceMethod = this.data[this.pos++]; break; case "acTL": this.animation = { numFrames: this.readUInt32(), numPlays: this.readUInt32() || 1 / 0, frames: [] }; break; case "PLTE": this.palette = this.read(e); break; case "fcTL": a && this.animation.frames.push(a), this.pos += 4, a = { width: this.readUInt32(), height: this.readUInt32(), xOffset: this.readUInt32(), yOffset: this.readUInt32() }, o = this.readUInt16(), i = this.readUInt16() || 100, a.delay = 1e3 * o / i, a.disposeOp = this.data[this.pos++], a.blendOp = this.data[this.pos++], a.data = []; break; case "IDAT": case "fdAT": for ("fdAT" === u && (this.pos += 4, e -= 4), t = (null != a ? a.data : void 0) || this.imgData, s = d = 0; 0 <= e ? d < e : d > e; s = 0 <= e ? ++d : --d) t.push(this.data[this.pos++]); break; case "tRNS": switch (this.transparency = {}, this.colorType) { case 3: if (r = this.palette.length / 3, this.transparency.indexed = this.read(e), this.transparency.indexed.length > r) throw new Error("More transparent colors than palette size"); if (h = r - this.transparency.indexed.length, h > 0) for (s = p = 0; 0 <= h ? p < h : p > h; s = 0 <= h ? ++p : --p) this.transparency.indexed.push(255); break; case 0: this.transparency.grayscale = this.read(e)[0]; break; case 2: this.transparency.rgb = this.read(e) } break; case "tEXt": f = this.read(e), c = f.indexOf(0), l = String.fromCharCode.apply(String, f.slice(0, c)), this.text[l] = String.fromCharCode.apply(String, f.slice(c + 1)); break; case "IEND": return a && this.animation.frames.push(a), this.colors = function () { switch (this.colorType) { case 0: case 3: case 4: return 1; case 2: case 6: return 3 } }.call(this), this.hasAlphaChannel = 4 === (g = this.colorType) || 6 === g, n = this.colors + (this.hasAlphaChannel ? 1 : 0), this.pixelBitlength = this.bits * n, this.colorSpace = function () { switch (this.colors) { case 1: return "DeviceGray"; case 3: return "DeviceRGB" } }.call(this), void (this.imgData = new Uint8Array(this.imgData)); default: this.pos += e } if (this.pos += 4, this.pos > this.data.length) throw new Error("Incomplete or corrupt PNG file") } } var n, r, i, o, a, s, l, u; e.load = function (t, n, r) { var i; return "function" == typeof n && (r = n), i = new XMLHttpRequest, i.open("GET", t, !0), i.responseType = "arraybuffer", i.onload = function () { var t, o; return t = new Uint8Array(i.response || i.mozResponseArrayBuffer), o = new e(t), "function" == typeof (null != n ? n.getContext : void 0) && o.render(n), "function" == typeof r ? r(o) : void 0 }, i.send(null) }, o = 0, i = 1, a = 2, r = 0, n = 1, e.prototype.read = function (t) { var e, n, r; for (r = [], e = n = 0; 0 <= t ? n < t : n > t; e = 0 <= t ? ++n : --n) r.push(this.data[this.pos++]); return r }, e.prototype.readUInt32 = function () { var t, e, n, r; return t = this.data[this.pos++] << 24, e = this.data[this.pos++] << 16, n = this.data[this.pos++] << 8, r = this.data[this.pos++], t | e | n | r }, e.prototype.readUInt16 = function () { var t, e; return t = this.data[this.pos++] << 8, e = this.data[this.pos++], t | e }, e.prototype.decodePixels = function (t) { var e, n, r, i, o, a, s, l, u, h, f, d, p, g, m, w, y, v, b, x, k, _, C; if (null == t && (t = this.imgData), 0 === t.length) return new Uint8Array(0); for (t = new c(t), t = t.getBytes(), d = this.pixelBitlength / 8, w = d * this.width, p = new Uint8Array(w * this.height), a = t.length, m = 0, g = 0, n = 0; g < a;) { switch (t[g++]) { case 0: for (i = b = 0; b < w; i = b += 1) p[n++] = t[g++]; break; case 1: for (i = x = 0; x < w; i = x += 1) e = t[g++], o = i < d ? 0 : p[n - d], p[n++] = (e + o) % 256; break; case 2: for (i = k = 0; k < w; i = k += 1) e = t[g++], r = (i - i % d) / d, y = m && p[(m - 1) * w + r * d + i % d], p[n++] = (y + e) % 256; break; case 3: for (i = _ = 0; _ < w; i = _ += 1) e = t[g++], r = (i - i % d) / d, o = i < d ? 0 : p[n - d], y = m && p[(m - 1) * w + r * d + i % d], p[n++] = (e + Math.floor((o + y) / 2)) % 256; break; case 4: for (i = C = 0; C < w; i = C += 1) e = t[g++], r = (i - i % d) / d, o = i < d ? 0 : p[n - d], 0 === m ? y = v = 0 : (y = p[(m - 1) * w + r * d + i % d], v = r && p[(m - 1) * w + (r - 1) * d + i % d]), s = o + y - v, l = Math.abs(s - o), h = Math.abs(s - y), f = Math.abs(s - v), u = l <= h && l <= f ? o : h <= f ? y : v, p[n++] = (e + u) % 256; break; default: throw new Error("Invalid filter algorithm: " + t[g - 1]) } m++ } return p }, e.prototype.decodePalette = function () { var t, e, n, r, i, o, a, s, c, l; for (r = this.palette, a = this.transparency.indexed || [], o = new Uint8Array((a.length || 0) + r.length), i = 0, n = r.length, t = 0, e = s = 0, c = r.length; s < c; e = s += 3) o[i++] = r[e], o[i++] = r[e + 1], o[i++] = r[e + 2], o[i++] = null != (l = a[t++]) ? l : 255; return o }, e.prototype.copyToImageData = function (t, e) { var n, r, i, o, a, s, c, l, u, h, f; if (r = this.colors, u = null, n = this.hasAlphaChannel, this.palette.length && (u = null != (f = this._decodedPalette) ? f : this._decodedPalette = this.decodePalette(), r = 4, n = !0), i = t.data || t, l = i.length, a = u || e, o = s = 0, 1 === r) for (; o < l;) c = u ? 4 * e[o / 4] : s, h = a[c++], i[o++] = h, i[o++] = h, i[o++] = h, i[o++] = n ? a[c++] : 255, s = c; else for (; o < l;) c = u ? 4 * e[o / 4] : s, i[o++] = a[c++], i[o++] = a[c++], i[o++] = a[c++], i[o++] = n ? a[c++] : 255, s = c }, e.prototype.decode = function () { var t; return t = new Uint8Array(this.width * this.height * 4), this.copyToImageData(t, this.decodePixels()), t }; try { l = t.document.createElement("canvas"), u = l.getContext("2d") } catch (t) { return -1 } return s = function (t) { var e; return u.width = t.width, u.height = t.height, u.clearRect(0, 0, t.width, t.height), u.putImageData(t, 0, 0), e = new Image, e.src = l.toDataURL(), e }, e.prototype.decodeFrames = function (t) { var e, n, r, i, o, a, c, l; if (this.animation) { for (c = this.animation.frames, l = [], n = o = 0, a = c.length; o < a; n = ++o) e = c[n], r = t.createImageData(e.width, e.height), i = this.decodePixels(new Uint8Array(e.data)), this.copyToImageData(r, i), e.imageData = r, l.push(e.image = s(r)); return l } }, e.prototype.renderFrame = function (t, e) { var n, o, s; return o = this.animation.frames, n = o[e], s = o[e - 1], 0 === e && t.clearRect(0, 0, this.width, this.height), (null != s ? s.disposeOp : void 0) === i ? t.clearRect(s.xOffset, s.yOffset, s.width, s.height) : (null != s ? s.disposeOp : void 0) === a && t.putImageData(s.imageData, s.xOffset, s.yOffset), n.blendOp === r && t.clearRect(n.xOffset, n.yOffset, n.width, n.height), t.drawImage(n.image, n.xOffset, n.yOffset) }, e.prototype.animate = function (t) { var e, n, r, i, o, a, s = this; return n = 0, a = this.animation, i = a.numFrames, r = a.frames, o = a.numPlays, (e = function () { var a, c; if (a = n++ % i, c = r[a], s.renderFrame(t, a), i > 1 && n / i < o) return s.animation._timeout = setTimeout(e, c.delay) })() }, e.prototype.stopAnimation = function () { var t; return clearTimeout(null != (t = this.animation) ? t._timeout : void 0) }, e.prototype.render = function (t) { var e, n; return t._png && t._png.stopAnimation(), t._png = this, t.width = this.width, t.height = this.height, e = t.getContext("2d"), this.animation ? (this.decodeFrames(e), this.animate(e)) : (n = e.createImageData(this.width, this.height), this.copyToImageData(n, this.decodePixels()), e.putImageData(n, 0, 0)) }, e }(), t.PNG = e }("undefined" != typeof window && window || void 0);/*
* Extracted from pdf.js
* https://github.com/andreasgal/pdf.js
*
* Copyright (c) 2011 Mozilla Foundation
*
* Contributors: Andreas Gal
* Chris G Jones
* Shaon Barman
* Vivien Nicolas <21@vingtetun.org>
* Justin D'Arcangelo
* Yury Delendik
*
*
*/
var s = function () { function t() { this.pos = 0, this.bufferLength = 0, this.eof = !1, this.buffer = null } return t.prototype = { ensureBuffer: function (t) { var e = this.buffer, n = e ? e.byteLength : 0; if (t < n) return e; for (var r = 512; r < t;) r <<= 1; for (var i = new Uint8Array(r), o = 0; o < n; ++o) i[o] = e[o]; return this.buffer = i }, getByte: function () { for (var t = this.pos; this.bufferLength <= t;) { if (this.eof) return null; this.readBlock() } return this.buffer[this.pos++] }, getBytes: function (t) { var e = this.pos; if (t) { this.ensureBuffer(e + t); for (var n = e + t; !this.eof && this.bufferLength < n;) this.readBlock(); var r = this.bufferLength; n > r && (n = r) } else { for (; !this.eof;) this.readBlock(); var n = this.bufferLength } return this.pos = n, this.buffer.subarray(e, n) }, lookChar: function () { for (var t = this.pos; this.bufferLength <= t;) { if (this.eof) return null; this.readBlock() } return String.fromCharCode(this.buffer[this.pos]) }, getChar: function () { for (var t = this.pos; this.bufferLength <= t;) { if (this.eof) return null; this.readBlock() } return String.fromCharCode(this.buffer[this.pos++]) }, makeSubStream: function (t, e, n) { for (var r = t + e; this.bufferLength <= r && !this.eof;) this.readBlock(); return new Stream(this.buffer, t, e, n) }, skip: function (t) { t || (t = 1), this.pos += t }, reset: function () { this.pos = 0 } }, t }(), c = function () { function t(t) { throw new Error(t) } function e(e) { var n = 0, r = e[n++], i = e[n++]; r != -1 && i != -1 || t("Invalid header in flate stream"), 8 != (15 & r) && t("Unknown compression method in flate stream"), ((r << 8) + i) % 31 != 0 && t("Bad FCHECK in flate stream"), 32 & i && t("FDICT bit set in flate stream"), this.bytes = e, this.bytesPos = n, this.codeSize = 0, this.codeBuf = 0, s.call(this) } if ("undefined" != typeof Uint32Array) { var n = new Uint32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), r = new Uint32Array([3, 4, 5, 6, 7, 8, 9, 10, 65547, 65549, 65551, 65553, 131091, 131095, 131099, 131103, 196643, 196651, 196659, 196667, 262211, 262227, 262243, 262259, 327811, 327843, 327875, 327907, 258, 258, 258]), i = new Uint32Array([1, 2, 3, 4, 65541, 65543, 131081, 131085, 196625, 196633, 262177, 262193, 327745, 327777, 393345, 393409, 459009, 459137, 524801, 525057, 590849, 591361, 657409, 658433, 724993, 727041, 794625, 798721, 868353, 876545]), o = [new Uint32Array([459008, 524368, 524304, 524568, 459024, 524400, 524336, 590016, 459016, 524384, 524320, 589984, 524288, 524416, 524352, 590048, 459012, 524376, 524312, 589968, 459028, 524408, 524344, 590032, 459020, 524392, 524328, 59e4, 524296, 524424, 524360, 590064, 459010, 524372, 524308, 524572, 459026, 524404, 524340, 590024, 459018, 524388, 524324, 589992, 524292, 524420, 524356, 590056, 459014, 524380, 524316, 589976, 459030, 524412, 524348, 590040, 459022, 524396, 524332, 590008, 524300, 524428, 524364, 590072, 459009, 524370, 524306, 524570, 459025, 524402, 524338, 590020, 459017, 524386, 524322, 589988, 524290, 524418, 524354, 590052, 459013, 524378, 524314, 589972, 459029, 524410, 524346, 590036, 459021, 524394, 524330, 590004, 524298, 524426, 524362, 590068, 459011, 524374, 524310, 524574, 459027, 524406, 524342, 590028, 459019, 524390, 524326, 589996, 524294, 524422, 524358, 590060, 459015, 524382, 524318, 589980, 459031, 524414, 524350, 590044, 459023, 524398, 524334, 590012, 524302, 524430, 524366, 590076, 459008, 524369, 524305, 524569, 459024, 524401, 524337, 590018, 459016, 524385, 524321, 589986, 524289, 524417, 524353, 590050, 459012, 524377, 524313, 589970, 459028, 524409, 524345, 590034, 459020, 524393, 524329, 590002, 524297, 524425, 524361, 590066, 459010, 524373, 524309, 524573, 459026, 524405, 524341, 590026, 459018, 524389, 524325, 589994, 524293, 524421, 524357, 590058, 459014, 524381, 524317, 589978, 459030, 524413, 524349, 590042, 459022, 524397, 524333, 590010, 524301, 524429, 524365, 590074, 459009, 524371, 524307, 524571, 459025, 524403, 524339, 590022, 459017, 524387, 524323, 589990, 524291, 524419, 524355, 590054, 459013, 524379, 524315, 589974, 459029, 524411, 524347, 590038, 459021, 524395, 524331, 590006, 524299, 524427, 524363, 590070, 459011, 524375, 524311, 524575, 459027, 524407, 524343, 590030, 459019, 524391, 524327, 589998, 524295, 524423, 524359, 590062, 459015, 524383, 524319, 589982, 459031, 524415, 524351, 590046, 459023, 524399, 524335, 590014, 524303, 524431, 524367, 590078, 459008, 524368, 524304, 524568, 459024, 524400, 524336, 590017, 459016, 524384, 524320, 589985, 524288, 524416, 524352, 590049, 459012, 524376, 524312, 589969, 459028, 524408, 524344, 590033, 459020, 524392, 524328, 590001, 524296, 524424, 524360, 590065, 459010, 524372, 524308, 524572, 459026, 524404, 524340, 590025, 459018, 524388, 524324, 589993, 524292, 524420, 524356, 590057, 459014, 524380, 524316, 589977, 459030, 524412, 524348, 590041, 459022, 524396, 524332, 590009, 524300, 524428, 524364, 590073, 459009, 524370, 524306, 524570, 459025, 524402, 524338, 590021, 459017, 524386, 524322, 589989, 524290, 524418, 524354, 590053, 459013, 524378, 524314, 589973, 459029, 524410, 524346, 590037, 459021, 524394, 524330, 590005, 524298, 524426, 524362, 590069, 459011, 524374, 524310, 524574, 459027, 524406, 524342, 590029, 459019, 524390, 524326, 589997, 524294, 524422, 524358, 590061, 459015, 524382, 524318, 589981, 459031, 524414, 524350, 590045, 459023, 524398, 524334, 590013, 524302, 524430, 524366, 590077, 459008, 524369, 524305, 524569, 459024, 524401, 524337, 590019, 459016, 524385, 524321, 589987, 524289, 524417, 524353, 590051, 459012, 524377, 524313, 589971, 459028, 524409, 524345, 590035, 459020, 524393, 524329, 590003, 524297, 524425, 524361, 590067, 459010, 524373, 524309, 524573, 459026, 524405, 524341, 590027, 459018, 524389, 524325, 589995, 524293, 524421, 524357, 590059, 459014, 524381, 524317, 589979, 459030, 524413, 524349, 590043, 459022, 524397, 524333, 590011, 524301, 524429, 524365, 590075, 459009, 524371, 524307, 524571, 459025, 524403, 524339, 590023, 459017, 524387, 524323, 589991, 524291, 524419, 524355, 590055, 459013, 524379, 524315, 589975, 459029, 524411, 524347, 590039, 459021, 524395, 524331, 590007, 524299, 524427, 524363, 590071, 459011, 524375, 524311, 524575, 459027, 524407, 524343, 590031, 459019, 524391, 524327, 589999, 524295, 524423, 524359, 590063, 459015, 524383, 524319, 589983, 459031, 524415, 524351, 590047, 459023, 524399, 524335, 590015, 524303, 524431, 524367, 590079]), 9], a = [new Uint32Array([327680, 327696, 327688, 327704, 327684, 327700, 327692, 327708, 327682, 327698, 327690, 327706, 327686, 327702, 327694, 0, 327681, 327697, 327689, 327705, 327685, 327701, 327693, 327709, 327683, 327699, 327691, 327707, 327687, 327703, 327695, 0]), 5]; return e.prototype = Object.create(s.prototype), e.prototype.getBits = function (e) { for (var n, r = this.codeSize, i = this.codeBuf, o = this.bytes, a = this.bytesPos; r < e;) "undefined" == typeof (n = o[a++]) && t("Bad encoding in flate stream"), i |= n << r, r += 8; return n = i & (1 << e) - 1, this.codeBuf = i >> e, this.codeSize = r -= e, this.bytesPos = a, n }, e.prototype.getCode = function (e) { for (var n = e[0], r = e[1], i = this.codeSize, o = this.codeBuf, a = this.bytes, s = this.bytesPos; i < r;) { var c; "undefined" == typeof (c = a[s++]) && t("Bad encoding in flate stream"), o |= c << i, i += 8 } var l = n[o & (1 << r) - 1], u = l >> 16, h = 65535 & l; return (0 == i || i < u || 0 == u) && t("Bad encoding in flate stream"), this.codeBuf = o >> u, this.codeSize = i - u, this.bytesPos = s, h }, e.prototype.generateHuffmanTable = function (t) { for (var e = t.length, n = 0, r = 0; r < e; ++r) t[r] > n && (n = t[r]); for (var i = 1 << n, o = new Uint32Array(i), a = 1, s = 0, c = 2; a <= n; ++a, s <<= 1, c <<= 1) for (var l = 0; l < e; ++l) if (t[l] == a) { for (var u = 0, h = s, r = 0; r < a; ++r) u = u << 1 | 1 & h, h >>= 1; for (var r = u; r < i; r += c) o[r] = a << 16 | l; ++s } return [o, n] }, e.prototype.readBlock = function () { function e(t, e, n, r, i) { for (var o = t.getBits(n) + r; o-- > 0;) e[_++] = i } var s = this.getBits(3); if (1 & s && (this.eof = !0), s >>= 1, 0 == s) { var c, l = this.bytes, u = this.bytesPos; "undefined" == typeof (c = l[u++]) && t("Bad block header in flate stream"); var h = c; "undefined" == typeof (c = l[u++]) && t("Bad block header in flate stream"), h |= c << 8, "undefined" == typeof (c = l[u++]) && t("Bad block header in flate stream"); var f = c; "undefined" == typeof (c = l[u++]) && t("Bad block header in flate stream"), f |= c << 8, f != (65535 & ~h) && t("Bad uncompressed block length in flate stream"), this.codeBuf = 0, this.codeSize = 0; var d = this.bufferLength, p = this.ensureBuffer(d + h), g = d + h; this.bufferLength = g; for (var m = d; m < g; ++m) { if ("undefined" == typeof (c = l[u++])) { this.eof = !0; break } p[m] = c } return void (this.bytesPos = u) } var w, y; if (1 == s) w = o, y = a; else if (2 == s) { for (var v = this.getBits(5) + 257, b = this.getBits(5) + 1, x = this.getBits(4) + 4, k = Array(n.length), _ = 0; _ < x;) k[n[_++]] = this.getBits(3); for (var C = this.generateHuffmanTable(k), A = 0, _ = 0, S = v + b, q = new Array(S) ; _ < S;) { var T = this.getCode(C); 16 == T ? e(this, q, 2, 3, A) : 17 == T ? e(this, q, 3, 3, A = 0) : 18 == T ? e(this, q, 7, 11, A = 0) : q[_++] = A = T } w = this.generateHuffmanTable(q.slice(0, v)), y = this.generateHuffmanTable(q.slice(v, S)) } else t("Unknown block type in flate stream"); for (var p = this.buffer, P = p ? p.length : 0, I = this.bufferLength; ;) { var E = this.getCode(w); if (E < 256) I + 1 >= P && (p = this.ensureBuffer(I + 1), P = p.length), p[I++] = E; else { if (256 == E) return void (this.bufferLength = I); E -= 257, E = r[E]; var O = E >> 16; O > 0 && (O = this.getBits(O)); var A = (65535 & E) + O; E = this.getCode(y), E = i[E], O = E >> 16, O > 0 && (O = this.getBits(O)); var F = (65535 & E) + O; I + A >= P && (p = this.ensureBuffer(I + A), P = p.length); for (var R = 0; R < A; ++R, ++I) p[I] = p[I - F] } } }, e } }(); return function (t) { var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; "undefined" == typeof t.btoa && (t.btoa = function (t) { var n, r, i, o, a, s, c, l, u = 0, h = 0, f = "", d = []; if (!t) return t; do n = t.charCodeAt(u++), r = t.charCodeAt(u++), i = t.charCodeAt(u++), l = n << 16 | r << 8 | i, o = l >> 18 & 63, a = l >> 12 & 63, s = l >> 6 & 63, c = 63 & l, d[h++] = e.charAt(o) + e.charAt(a) + e.charAt(s) + e.charAt(c); while (u < t.length); f = d.join(""); var p = t.length % 3; return (p ? f.slice(0, p - 3) : f) + "===".slice(p || 3) }), "undefined" == typeof t.atob && (t.atob = function (t) { var n, r, i, o, a, s, c, l, u = 0, h = 0, f = "", d = []; if (!t) return t; t += ""; do o = e.indexOf(t.charAt(u++)), a = e.indexOf(t.charAt(u++)), s = e.indexOf(t.charAt(u++)), c = e.indexOf(t.charAt(u++)), l = o << 18 | a << 12 | s << 6 | c, n = l >> 16 & 255, r = l >> 8 & 255, i = 255 & l, 64 == s ? d[h++] = String.fromCharCode(n) : 64 == c ? d[h++] = String.fromCharCode(n, r) : d[h++] = String.fromCharCode(n, r, i); while (u < t.length); return f = d.join("") }), Array.prototype.map || (Array.prototype.map = function (t) { if (void 0 === this || null === this || "function" != typeof t) throw new TypeError; for (var e = Object(this), n = e.length >>> 0, r = new Array(n), i = arguments.length > 1 ? arguments[1] : void 0, o = 0; o < n; o++) o in e && (r[o] = t.call(i, e[o], o, e)); return r }), Array.isArray || (Array.isArray = function (t) { return "[object Array]" === Object.prototype.toString.call(t) }), Array.prototype.forEach || (Array.prototype.forEach = function (t, e) { if (void 0 === this || null === this || "function" != typeof t) throw new TypeError; for (var n = Object(this), r = n.length >>> 0, i = 0; i < r; i++) i in n && t.call(e, n[i], i, n) }), Object.keys || (Object.keys = function () { var t = Object.prototype.hasOwnProperty, e = !{ toString: null }.propertyIsEnumerable("toString"), n = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], r = n.length; return function (i) { if ("object" != typeof i && ("function" != typeof i || null === i)) throw new TypeError; var o, a, s = []; for (o in i) t.call(i, o) && s.push(o); if (e) for (a = 0; a < r; a++) t.call(i, n[a]) && s.push(n[a]); return s } }()), String.prototype.trim || (String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, "") }), String.prototype.trimLeft || (String.prototype.trimLeft = function () { return this.replace(/^\s+/g, "") }), String.prototype.trimRight || (String.prototype.trimRight = function () { return this.replace(/\s+$/g, "") }) }("undefined" != typeof self && self || "undefined" != typeof window && window || void 0), e
});
//================================================================================================================================================
/*!
Autosize v1.18.6 - 2014-03-13
Automatically adjust textarea height based on user input.
(c) 2014 Jack Moore - http://www.jacklmoore.com/autosize
license: http://www.opensource.org/licenses/mit-license.php
===== DZ: USED FOR custom text boxes class custom_textarea (auto text size grow VERTICAL ONLY)
DZ 5jun17: editing one line - changing width of utility div according to scaling (for mobile)
*/
(function (e) {
var t, o = { className: "autosizejs", id: "autosizejs", append: "", callback: !1, resizeDelay: 10, placeholder: !0 }, i = '', n = ["fontFamily", "fontSize", "fontWeight", "fontStyle", "letterSpacing", "textTransform", "wordSpacing", "textIndent"], a = e(i).data("autosize", !0)[0]; a.style.lineHeight = "99px", "99px" === e(a).css("lineHeight") && n.push("lineHeight"), a.style.lineHeight = "", e.fn.autosize = function (i) {
return this.length ?
(i = e.extend({}, o, i || {}), a.parentNode !== document.body && e(document.body).append(a),
this.each(function () {
function o() {
var t, o = window.getComputedStyle ? window.getComputedStyle(u, null) : !1;
o ? (t = u.getBoundingClientRect().width, 0 === t && (t = parseInt(o.width, 10)), e.each(["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"], function (e, i) {
t -= parseInt(o[i], 10)
//DZ 5jun17: a tough one. this component (already old version) cant cope with our scaling. hopefully this is only place needed to be fixed
//})) : t = Math.max(p.width(), 0), a.style.width = t + "px"
//DZ 13jun17: adding support for autosizer for multiple scales
//})) : t = Math.max(p.width(), 0), a.style.width = (t/desLogic.editor_scale) + "px"
//DZ 7jul17: that just wasnt a good enough fix
//})) : t = Math.max(p.width(), 0), a.style.width = (t / window.current_autosize_ratio) + "px"
})) : t = Math.max(p.width(), 0), a.style.width = (t / get_current_autosize_ratio()) + "px"
}
function s() {
var s = {};
if (t = u, a.className = i.className, a.id = i.id, d = parseInt(p.css("maxHeight"), 10), e.each(n, function (e, t) {
s[t] = p.css(t)
}), e(a).css(s).attr("wrap", p.attr("wrap")), o(), window.chrome) {
var r = u.style.width;
u.style.width = "0px", u.offsetWidth, u.style.width = r
}
}
function r() {
var e, n;
t !== u ? s() : o(), a.value = !u.value && i.placeholder ? (p.attr("placeholder") || "") + i.append : u.value + i.append, a.style.overflowY = u.style.overflowY, n = parseInt(u.style.height, 10), a.scrollTop = 0, a.scrollTop = 9e4, e = a.scrollTop, d && e > d ? (u.style.overflowY = "scroll", e = d) : (u.style.overflowY = "hidden", c > e && (e = c)), e += w, n !== e && (u.style.height = e + "px", f && i.callback.call(u, u))
}
function l() {
clearTimeout(h), h = setTimeout(function () {
var e = p.width();
e !== g && (g = e, r())
}, parseInt(i.resizeDelay, 10))
}
var d, c, h, u = this,
p = e(u),
w = 0,
f = e.isFunction(i.callback),
z = {
height: u.style.height,
overflow: u.style.overflow,
overflowY: u.style.overflowY,
wordWrap: u.style.wordWrap,
resize: u.style.resize
},
g = p.width();
p.data("autosize") || (p.data("autosize", !0), ("border-box" === p.css("box-sizing") || "border-box" === p.css("-moz-box-sizing") || "border-box" === p.css("-webkit-box-sizing")) && (w = p.outerHeight() - p.height()), c = Math.max(parseInt(p.css("minHeight"), 10) - w || 0, p.height()), p.css({
overflow: "hidden",
overflowY: "hidden",
wordWrap: "break-word",
resize: "none" === p.css("resize") || "vertical" === p.css("resize") ? "none" : "horizontal"
}), "onpropertychange" in u ? "oninput" in u ? p.on("input.autosize keyup.autosize", r) : p.on("propertychange.autosize", function () {
"value" === event.propertyName && r()
}) : p.on("input.autosize", r), i.resizeDelay !== !1 && e(window).on("resize.autosize", l), p.on("autosize.resize", r), p.on("autosize.resizeIncludeStyle", function () {
t = null, r()
}), p.on("autosize.destroy", function () {
t = null, clearTimeout(h), e(window).off("resize", l), p.off("autosize").off(".autosize").css(z).removeData("autosize")
}), r())
})) : this
}
})(window.jQuery || window.$);
// this.each(function () { function o() { var t, o = window.getComputedStyle ? window.getComputedStyle(u, null) : !1; o ? (t = u.getBoundingClientRect().width, 0 === t && (t = parseInt(o.width, 10)), e.each(["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"], function (e, i) { t -= parseInt(o[i], 10) })) : t = Math.max(p.width(), 0), a.style.width = t + "px" } function s() { var s = {}; if (t = u, a.className = i.className, a.id = i.id, d = parseInt(p.css("maxHeight"), 10), e.each(n, function (e, t) { s[t] = p.css(t) }), e(a).css(s).attr("wrap", p.attr("wrap")), o(), window.chrome) { var r = u.style.width; u.style.width = "0px", u.offsetWidth, u.style.width = r } } function r() { var e, n; t !== u ? s() : o(), a.value = !u.value && i.placeholder ? (p.attr("placeholder") || "") + i.append : u.value + i.append, a.style.overflowY = u.style.overflowY, n = parseInt(u.style.height, 10), a.scrollTop = 0, a.scrollTop = 9e4, e = a.scrollTop, d && e > d ? (u.style.overflowY = "scroll", e = d) : (u.style.overflowY = "hidden", c > e && (e = c)), e += w, n !== e && (u.style.height = e + "px", f && i.callback.call(u, u)) } function l() { clearTimeout(h), h = setTimeout(function () { var e = p.width(); e !== g && (g = e, r()) }, parseInt(i.resizeDelay, 10)) } var d, c, h, u = this, p = e(u), w = 0, f = e.isFunction(i.callback), z = { height: u.style.height, overflow: u.style.overflow, overflowY: u.style.overflowY, wordWrap: u.style.wordWrap, resize: u.style.resize }, g = p.width(); p.data("autosize") || (p.data("autosize", !0), ("border-box" === p.css("box-sizing") || "border-box" === p.css("-moz-box-sizing") || "border-box" === p.css("-webkit-box-sizing")) && (w = p.outerHeight() - p.height()), c = Math.max(parseInt(p.css("minHeight"), 10) - w || 0, p.height()), p.css({ overflow: "hidden", overflowY: "hidden", wordWrap: "break-word", resize: "none" === p.css("resize") || "vertical" === p.css("resize") ? "none" : "horizontal" }), "onpropertychange" in u ? "oninput" in u ? p.on("input.autosize keyup.autosize", r) : p.on("propertychange.autosize", function () { "value" === event.propertyName && r() }) : p.on("input.autosize", r), i.resizeDelay !== !1 && e(window).on("resize.autosize", l), p.on("autosize.resize", r), p.on("autosize.resizeIncludeStyle", function () { t = null, r() }), p.on("autosize.destroy", function () { t = null, clearTimeout(h), e(window).off("resize", l), p.off("autosize").off(".autosize").css(z).removeData("autosize") }), r()) })) : this
// }
//})(window.jQuery || window.$);
/**
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
*
* @version 1.0.2
* @codingstandard ftlabs-jsv2
* @copyright The Financial Times Limited [All Rights Reserved]
* @license MIT License (see LICENSE.txt)
*/
function FastClick(e, t) { "use strict"; function r(e, t) { return function () { return e.apply(t, arguments) } } var n; t = t || {}; this.trackingClick = false; this.trackingClickStart = 0; this.targetElement = null; this.touchStartX = 0; this.touchStartY = 0; this.lastTouchIdentifier = 0; this.touchBoundary = t.touchBoundary || 10; this.layer = e; this.tapDelay = t.tapDelay || 200; if (FastClick.notNeeded(e)) { return } var i = ["onMouse", "onClick", "onTouchStart", "onTouchMove", "onTouchEnd", "onTouchCancel"]; var s = this; for (var o = 0, u = i.length; o < u; o++) { s[i[o]] = r(s[i[o]], s) } if (deviceIsAndroid) { e.addEventListener("mouseover", this.onMouse, true); e.addEventListener("mousedown", this.onMouse, true); e.addEventListener("mouseup", this.onMouse, true) } e.addEventListener("click", this.onClick, true); e.addEventListener("touchstart", this.onTouchStart, false); e.addEventListener("touchmove", this.onTouchMove, false); e.addEventListener("touchend", this.onTouchEnd, false); e.addEventListener("touchcancel", this.onTouchCancel, false); if (!Event.prototype.stopImmediatePropagation) { e.removeEventListener = function (t, n, r) { var i = Node.prototype.removeEventListener; if (t === "click") { i.call(e, t, n.hijacked || n, r) } else { i.call(e, t, n, r) } }; e.addEventListener = function (t, n, r) { var i = Node.prototype.addEventListener; if (t === "click") { i.call(e, t, n.hijacked || (n.hijacked = function (e) { if (!e.propagationStopped) { n(e) } }), r) } else { i.call(e, t, n, r) } } } if (typeof e.onclick === "function") { n = e.onclick; e.addEventListener("click", function (e) { n(e) }, false); e.onclick = null } } var deviceIsAndroid = navigator.userAgent.indexOf("Android") > 0; var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent); var deviceIsIOS4 = deviceIsIOS && /OS 4_\d(_\d)?/.test(navigator.userAgent); var deviceIsIOSWithBadTarget = deviceIsIOS && /OS ([6-9]|\d{2})_\d/.test(navigator.userAgent); var deviceIsBlackBerry10 = navigator.userAgent.indexOf("BB10") > 0; FastClick.prototype.needsClick = function (e) { "use strict"; switch (e.nodeName.toLowerCase()) { case "button": case "select": case "textarea": if (e.disabled) { return true } break; case "input": if (deviceIsIOS && e.type === "file" || e.disabled) { return true } break; case "label": case "video": return true } return /\bneedsclick\b/.test(e.className) }; FastClick.prototype.needsFocus = function (e) { "use strict"; switch (e.nodeName.toLowerCase()) { case "textarea": return true; case "select": return !deviceIsAndroid; case "input": switch (e.type) { case "button": case "checkbox": case "file": case "image": case "radio": case "submit": return false } return !e.disabled && !e.readOnly; default: return /\bneedsfocus\b/.test(e.className) } }; FastClick.prototype.sendClick = function (e, t) { "use strict"; var n, r; if (document.activeElement && document.activeElement !== e) { document.activeElement.blur() } r = t.changedTouches[0]; n = document.createEvent("MouseEvents"); n.initMouseEvent(this.determineEventType(e), true, true, window, 1, r.screenX, r.screenY, r.clientX, r.clientY, false, false, false, false, 0, null); n.forwardedTouchEvent = true; e.dispatchEvent(n) }; FastClick.prototype.determineEventType = function (e) { "use strict"; if (deviceIsAndroid && e.tagName.toLowerCase() === "select") { return "mousedown" } return "click" }; FastClick.prototype.focus = function (e) { "use strict"; var t; if (deviceIsIOS && e.setSelectionRange && e.type.indexOf("date") !== 0 && e.type !== "time") { t = e.value.length; e.setSelectionRange(t, t) } else { e.focus() } }; FastClick.prototype.updateScrollParent = function (e) { "use strict"; var t, n; t = e.fastClickScrollParent; if (!t || !t.contains(e)) { n = e; do { if (n.scrollHeight > n.offsetHeight) { t = n; e.fastClickScrollParent = n; break } n = n.parentElement } while (n) } if (t) { t.fastClickLastScrollTop = t.scrollTop } }; FastClick.prototype.getTargetElementFromEventTarget = function (e) { "use strict"; if (e.nodeType === Node.TEXT_NODE) { return e.parentNode } return e }; FastClick.prototype.onTouchStart = function (e) { "use strict"; var t, n, r; if (e.targetTouches.length > 1) { return true } t = this.getTargetElementFromEventTarget(e.target); n = e.targetTouches[0]; if (deviceIsIOS) { r = window.getSelection(); if (r.rangeCount && !r.isCollapsed) { return true } if (!deviceIsIOS4) { if (n.identifier === this.lastTouchIdentifier) { e.preventDefault(); return false } this.lastTouchIdentifier = n.identifier; this.updateScrollParent(t) } } this.trackingClick = true; this.trackingClickStart = e.timeStamp; this.targetElement = t; this.touchStartX = n.pageX; this.touchStartY = n.pageY; if (e.timeStamp - this.lastClickTime < this.tapDelay) { e.preventDefault() } return true }; FastClick.prototype.touchHasMoved = function (e) { "use strict"; var t = e.changedTouches[0], n = this.touchBoundary; if (Math.abs(t.pageX - this.touchStartX) > n || Math.abs(t.pageY - this.touchStartY) > n) { return true } return false }; FastClick.prototype.onTouchMove = function (e) { "use strict"; if (!this.trackingClick) { return true } if (this.targetElement !== this.getTargetElementFromEventTarget(e.target) || this.touchHasMoved(e)) { this.trackingClick = false; this.targetElement = null } return true }; FastClick.prototype.findControl = function (e) { "use strict"; if (e.control !== undefined) { return e.control } if (e.htmlFor) { return document.getElementById(e.htmlFor) } return e.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea") }; FastClick.prototype.onTouchEnd = function (e) { "use strict"; var t, n, r, i, s, o = this.targetElement; if (!this.trackingClick) { return true } if (e.timeStamp - this.lastClickTime < this.tapDelay) { this.cancelNextClick = true; return true } this.cancelNextClick = false; this.lastClickTime = e.timeStamp; n = this.trackingClickStart; this.trackingClick = false; this.trackingClickStart = 0; if (deviceIsIOSWithBadTarget) { s = e.changedTouches[0]; o = document.elementFromPoint(s.pageX - window.pageXOffset, s.pageY - window.pageYOffset) || o; o.fastClickScrollParent = this.targetElement.fastClickScrollParent } r = o.tagName.toLowerCase(); if (r === "label") { t = this.findControl(o); if (t) { this.focus(o); if (deviceIsAndroid) { return false } o = t } } else if (this.needsFocus(o)) { if (e.timeStamp - n > 100 || deviceIsIOS && window.top !== window && r === "input") { this.targetElement = null; return false } this.focus(o); this.sendClick(o, e); if (!deviceIsIOS || r !== "select") { this.targetElement = null; e.preventDefault() } return false } if (deviceIsIOS && !deviceIsIOS4) { i = o.fastClickScrollParent; if (i && i.fastClickLastScrollTop !== i.scrollTop) { return true } } if (!this.needsClick(o)) { e.preventDefault(); this.sendClick(o, e) } return false }; FastClick.prototype.onTouchCancel = function () { "use strict"; this.trackingClick = false; this.targetElement = null }; FastClick.prototype.onMouse = function (e) { "use strict"; if (!this.targetElement) { return true } if (e.forwardedTouchEvent) { return true } if (!e.cancelable) { return true } if (!this.needsClick(this.targetElement) || this.cancelNextClick) { if (e.stopImmediatePropagation) { e.stopImmediatePropagation() } else { e.propagationStopped = true } e.stopPropagation(); e.preventDefault(); return false } return true }; FastClick.prototype.onClick = function (e) { "use strict"; var t; if (this.trackingClick) { this.targetElement = null; this.trackingClick = false; return true } if (e.target.type === "submit" && e.detail === 0) { return true } t = this.onMouse(e); if (!t) { this.targetElement = null } return t }; FastClick.prototype.destroy = function () { "use strict"; var e = this.layer; if (deviceIsAndroid) { e.removeEventListener("mouseover", this.onMouse, true); e.removeEventListener("mousedown", this.onMouse, true); e.removeEventListener("mouseup", this.onMouse, true) } e.removeEventListener("click", this.onClick, true); e.removeEventListener("touchstart", this.onTouchStart, false); e.removeEventListener("touchmove", this.onTouchMove, false); e.removeEventListener("touchend", this.onTouchEnd, false); e.removeEventListener("touchcancel", this.onTouchCancel, false) }; FastClick.notNeeded = function (e) { "use strict"; var t; var n; var r; if (typeof window.ontouchstart === "undefined") { return true } n = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1]; if (n) { if (deviceIsAndroid) { t = document.querySelector("meta[name=viewport]"); if (t) { if (t.content.indexOf("user-scalable=no") !== -1) { return true } if (n > 31 && document.documentElement.scrollWidth <= window.outerWidth) { return true } } } else { return true } } if (deviceIsBlackBerry10) { r = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/); if (r[1] >= 10 && r[2] >= 3) { t = document.querySelector("meta[name=viewport]"); if (t) { if (t.content.indexOf("user-scalable=no") !== -1) { return true } if (document.documentElement.scrollWidth <= window.outerWidth) { return true } } } } if (e.style.msTouchAction === "none") { return true } return false }; FastClick.attach = function (e, t) { "use strict"; return new FastClick(e, t) }; if (typeof define == "function" && typeof define.amd == "object" && define.amd) { define(function () { "use strict"; return FastClick }) } else if (typeof module !== "undefined" && module.exports) { module.exports = FastClick.attach; module.exports.FastClick = FastClick } else { window.FastClick = FastClick }
/*-----------------------------------------------------------------------------*/
/* adds IE support for pointer-events:none https://github.com/kmewhort/pointer_events_polyfill/blob/master/pointer_events_polyfill.js
/*
* Pointer Events Polyfill: Adds support for the style attribute "pointer-events: none" to browsers without this feature (namely, IE).
* (c) 2013, Kent Mewhort, licensed under BSD. See LICENSE.txt for details.
*/
// constructor
function PointerEventsPolyfill(options) {
// set defaults
this.options = {
selector: '*',
mouseEvents: ['click', 'dblclick', 'mousedown', 'mouseup'],
usePolyfillIf: function () {
if (navigator.appName == 'Microsoft Internet Explorer') {
var agent = navigator.userAgent;
if (agent.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/) != null) {
var version = parseFloat(RegExp.$1);
if (version < 11)
return true;
}
}
return false;
}
};
if (options) {
var obj = this;
$.each(options, function (k, v) {
obj.options[k] = v;
});
}
if (this.options.usePolyfillIf())
this.register_mouse_events();
}
// singleton initializer
PointerEventsPolyfill.initialize = function (options) {
if (PointerEventsPolyfill.singleton == null)
PointerEventsPolyfill.singleton = new PointerEventsPolyfill(options);
return PointerEventsPolyfill.singleton;
};
// handle mouse events w/ support for pointer-events: none
PointerEventsPolyfill.prototype.register_mouse_events = function () {
// register on all elements (and all future elements) matching the selector
$(document).on(this.options.mouseEvents.join(" "), this.options.selector, function (e) {
if ($(this).css('pointer-events') == 'none') {
// peak at the element below
var origDisplayAttribute = $(this).css('display');
$(this).css('display', 'none');
var underneathElem = document.elementFromPoint(e.clientX, e.clientY);
if (origDisplayAttribute)
$(this)
.css('display', origDisplayAttribute);
else
$(this).css('display', '');
// fire the mouse event on the element below
e.target = underneathElem;
$(underneathElem).trigger(e);
return false;
}
return true;
});
};
//---------------- get browser type: -----------------
// TODO: remove. switch to getBrowser
function sayswho() {
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + (tem[1] || '');
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+)/)
if (tem != null) return 'Opera ' + tem[1];
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
return M.join(' ');
}
function isChrome() {
const isChromium = window.chrome,
winNav = window.navigator,
vendorName = winNav.vendor,
isOpera = typeof window.opr !== "undefined",
isIEedge = winNav.userAgent.toLowerCase().indexOf("edge") >= 0,
isIOSChrome = winNav.userAgent.toLowerCase().match("CriOS");
const isChrome =
isIOSChrome ||
(isChromium !== null &&
typeof isChromium !== "undefined" &&
vendorName === "Google Inc." &&
isOpera === false &&
isIEedge === false);
return isChrome;
}
function getBrowser() {
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return {name:'IE',version:(tem[1] || '')};
}
if(M[1]=== 'Chrome'){
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem != null) return {name:tem[1].replace('OPR', 'Opera'),version:tem[2]};
}
M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem = ua.match(/version\/(\d+)/i))!= null)
M.splice(1, 1, tem[1]);
return {name:M[0], version:M[1]};
}
function sayswho_majorVersion()
{
var ret = null;
var a = sayswho().split(' ');
if (a != null && a.length > 1)
ret = a[1];
return ret;
}
//---------------- get device type: -----------------
/*! Categorizr.js: Device Detection Scripts | https://github.com/Skookum/categorizr.js/blob/master/license.md */
/*YZ 25MAY : ADDING ChromeOS check and identify as desktop to solve a bug that does not allow upload images in chromeOS*/
(function (name, context, definition) { typeof module != "undefined" ? module.exports = definition(name, context) : typeof define == "function" && typeof define.amd == "object" ? define(definition) : context[name] = definition(name, context) })("categorizr", this, function (name, context) { function _setDeviceBooleans() { var i = deviceTypes.length; while (i--) categorizr["is" + deviceTypes[i]] = is(deviceTypes[i].toLowerCase()), is$ && (context.$["is" + deviceTypes[i]] = is(deviceTypes[i].toLowerCase())) } function _setClassName() { isBrowser && (docElement.className = docElement.className.replace(/(^|\s)desktop|tablet|tv|mobile(\s|$)/, "$1$2") + (" " + device)) } function _update() { _setDeviceBooleans(), _setClassName(), eventEmitter && context.$(context).trigger("deviceChange", [{ type: device }]) } var key, isBrowser = context != null && context == context.window, isNode = !isBrowser, is$ = isBrowser && context.$, eventEmitter = function () { var e; return is$ && (e = context.$("").trigger), e }(), docElement = isNode ? null : document.documentElement, deviceTypes = "Tv Desktop Tablet Mobile".split(" "), test = function (ua) { return ua.match(/\bCrOS\b/)? "desktop" : ua.match(/GoogleTV|SmartTV|Internet.TV|NetCast|NETTV|AppleTV|boxee|Kylo|Roku|DLNADOC|CE\-HTML/i) ? "tv" : ua.match(/Xbox|PLAYSTATION.3|Wii/i) ? "tv" : ua.match(/iPad/i) || ua.match(/tablet/i) && !ua.match(/RX-34/i) || ua.match(/FOLIO/i) ? "tablet" : ua.match(/Linux/i) && ua.match(/Android/i) && !ua.match(/Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945/i) ? "tablet" : ua.match(/Kindle/i) || ua.match(/Mac.OS/i) && ua.match(/Silk/i) ? "tablet" : ua.match(/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook/i) || ua.match(/MB511/i) && ua.match(/RUTEM/i) ? "tablet" : ua.match(/BOLT|Fennec|Iris|Maemo|Minimo|Mobi|mowser|NetFront|Novarra|Prism|RX-34|Skyfire|Tear|XV6875|XV6975|Google.Wireless.Transcoder/i) ? "mobile" : ua.match(/Opera/i) && ua.match(/Windows.NT.5/i) && ua.match(/HTC|Xda|Mini|Vario|SAMSUNG\-GT\-i8000|SAMSUNG\-SGH\-i9/i) ? "mobile" : ua.match(/Windows.(NT|XP|ME|9)/) && !ua.match(/Phone/i) || ua.match(/Win(9|.9|NT)/i) ? "desktop" : ua.match(/Macintosh|PowerPC/i) && !ua.match(/Silk/i) ? "desktop" : ua.match(/Linux/i) && ua.match(/X11/i) ? "desktop" : ua.match(/Solaris|SunOS|BSD/i) ? "desktop" : ua.match(/Bot|Crawler|Spider|Yahoo|ia_archiver|Covario-IDS|findlinks|DataparkSearch|larbin|Mediapartners-Google|NG-Search|Snappy|Teoma|Jeeves|TinEye/i) && !ua.match(/Mobile/i) ? "desktop" : "mobile" }, device = test(context.navigator ? context.navigator.userAgent : context.request ? context.request.headers["user-agent"] : "No User-Agent Provided"), is = function (type) { return device === type }, categorizr = function () { var args = [].slice.call(arguments, 0); return args.length === 2 && device === args[0] ? (device = args[1], _update()) : args.length === 1 && typeof args[0] == "string" && (device = args[0], _update()), device }; categorizr.is = is, categorizr.test = test, _update(); if (is$) { for (key in categorizr) Object.hasOwnProperty.call(categorizr, key) && (context.$[key == "test" ? "testUserAgent" : key == "is" ? "isDeviceType" : key] = categorizr[key]); context.$.categorizr = categorizr } return categorizr })
//YZ 27oct : Adding a test function - returns true if OS is iOS
function isIOS()
{
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
return iOS;
}
/*! jQuery Validation Plugin - v1.13.0 - 7/1/2014
* http://jqueryvalidation.org/
* Copyright (c) 2014 Jörn Zaefferer; Licensed MIT */
!function (a) { "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery) }(function (a) { a.extend(a.fn, { validate: function (b) { if (!this.length) return void (b && b.debug && window.console && console.warn("Nothing selected, can't validate, returning nothing.")); var c = a.data(this[0], "validator"); return c ? c : (this.attr("novalidate", "novalidate"), c = new a.validator(b, this[0]), a.data(this[0], "validator", c), c.settings.onsubmit && (this.validateDelegate(":submit", "click", function (b) { c.settings.submitHandler && (c.submitButton = b.target), a(b.target).hasClass("cancel") && (c.cancelSubmit = !0), void 0 !== a(b.target).attr("formnovalidate") && (c.cancelSubmit = !0) }), this.submit(function (b) { function d() { var d; return c.settings.submitHandler ? (c.submitButton && (d = a("").attr("name", c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)), c.settings.submitHandler.call(c, c.currentForm, b), c.submitButton && d.remove(), !1) : !0 } return c.settings.debug && b.preventDefault(), c.cancelSubmit ? (c.cancelSubmit = !1, d()) : c.form() ? c.pendingRequest ? (c.formSubmitted = !0, !1) : d() : (c.focusInvalid(), !1) })), c) }, valid: function () { var b, c; return a(this[0]).is("form") ? b = this.validate().form() : (b = !0, c = a(this[0].form).validate(), this.each(function () { b = c.element(this) && b })), b }, removeAttrs: function (b) { var c = {}, d = this; return a.each(b.split(/\s/), function (a, b) { c[b] = d.attr(b), d.removeAttr(b) }), c }, rules: function (b, c) { var d, e, f, g, h, i, j = this[0]; if (b) switch (d = a.data(j.form, "validator").settings, e = d.rules, f = a.validator.staticRules(j), b) { case "add": a.extend(f, a.validator.normalizeRule(c)), delete f.messages, e[j.name] = f, c.messages && (d.messages[j.name] = a.extend(d.messages[j.name], c.messages)); break; case "remove": return c ? (i = {}, a.each(c.split(/\s/), function (b, c) { i[c] = f[c], delete f[c], "required" === c && a(j).removeAttr("aria-required") }), i) : (delete e[j.name], f) } return g = a.validator.normalizeRules(a.extend({}, a.validator.classRules(j), a.validator.attributeRules(j), a.validator.dataRules(j), a.validator.staticRules(j)), j), g.required && (h = g.required, delete g.required, g = a.extend({ required: h }, g), a(j).attr("aria-required", "true")), g.remote && (h = g.remote, delete g.remote, g = a.extend(g, { remote: h })), g } }), a.extend(a.expr[":"], { blank: function (b) { return !a.trim("" + a(b).val()) }, filled: function (b) { return !!a.trim("" + a(b).val()) }, unchecked: function (b) { return !a(b).prop("checked") } }), a.validator = function (b, c) { this.settings = a.extend(!0, {}, a.validator.defaults, b), this.currentForm = c, this.init() }, a.validator.format = function (b, c) { return 1 === arguments.length ? function () { var c = a.makeArray(arguments); return c.unshift(b), a.validator.format.apply(this, c) } : (arguments.length > 2 && c.constructor !== Array && (c = a.makeArray(arguments).slice(1)), c.constructor !== Array && (c = [c]), a.each(c, function (a, c) { b = b.replace(new RegExp("\\MS_17.html" + a + "\\MS_18.html", "g"), function () { return c }) }), b) }, a.extend(a.validator, { defaults: { messages: {}, groups: {}, rules: {}, errorClass: "error", validClass: "valid", errorElement: "label", focusInvalid: !0, errorContainer: a([]), errorLabelContainer: a([]), onsubmit: !0, ignore: ":hidden", ignoreTitle: !1, onfocusin: function (a) { this.lastActive = a, this.settings.focusCleanup && !this.blockFocusCleanup && (this.settings.unhighlight && this.settings.unhighlight.call(this, a, this.settings.errorClass, this.settings.validClass), this.hideThese(this.errorsFor(a))) }, onfocusout: function (a) { this.checkable(a) || !(a.name in this.submitted) && this.optional(a) || this.element(a) }, onkeyup: function (a, b) { (9 !== b.which || "" !== this.elementValue(a)) && (a.name in this.submitted || a === this.lastElement) && this.element(a) }, onclick: function (a) { a.name in this.submitted ? this.element(a) : a.parentNode.name in this.submitted && this.element(a.parentNode) }, highlight: function (b, c, d) { "radio" === b.type ? this.findByName(b.name).addClass(c).removeClass(d) : a(b).addClass(c).removeClass(d) }, unhighlight: function (b, c, d) { "radio" === b.type ? this.findByName(b.name).removeClass(c).addClass(d) : a(b).removeClass(c).addClass(d) } }, setDefaults: function (b) { a.extend(a.validator.defaults, b) }, messages: { required: "This field is required.", remote: "Please fix this field.", email: "Please enter a valid email address.", url: "Please enter a valid URL.", date: "Please enter a valid date.", dateISO: "Please enter a valid date ( ISO ).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", maxlength: a.validator.format("Please enter no more than {0} characters."), minlength: a.validator.format("Please enter at least {0} characters."), rangelength: a.validator.format("Please enter a value between {0} and {1} characters long."), range: a.validator.format("Please enter a value between {0} and {1}."), max: a.validator.format("Please enter a value less than or equal to {0}."), min: a.validator.format("Please enter a value greater than or equal to {0}.") }, autoCreateRanges: !1, prototype: { init: function () { function b(b) { var c = a.data(this[0].form, "validator"), d = "on" + b.type.replace(/^validate/, ""), e = c.settings; e[d] && !this.is(e.ignore) && e[d].call(c, this[0], b) } this.labelContainer = a(this.settings.errorLabelContainer), this.errorContext = this.labelContainer.length && this.labelContainer || a(this.currentForm), this.containers = a(this.settings.errorContainer).add(this.settings.errorLabelContainer), this.submitted = {}, this.valueCache = {}, this.pendingRequest = 0, this.pending = {}, this.invalid = {}, this.reset(); var c, d = this.groups = {}; a.each(this.settings.groups, function (b, c) { "string" == typeof c && (c = c.split(/\s/)), a.each(c, function (a, c) { d[c] = b }) }), c = this.settings.rules, a.each(c, function (b, d) { c[b] = a.validator.normalizeRule(d) }), a(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox']", "focusin focusout keyup", b).validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", b), this.settings.invalidHandler && a(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler), a(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required", "true") }, form: function () { return this.checkForm(), a.extend(this.submitted, this.errorMap), this.invalid = a.extend({}, this.errorMap), this.valid() || a(this.currentForm).triggerHandler("invalid-form", [this]), this.showErrors(), this.valid() }, checkForm: function () { this.prepareForm(); for (var a = 0, b = this.currentElements = this.elements() ; b[a]; a++) this.check(b[a]); return this.valid() }, element: function (b) { var c = this.clean(b), d = this.validationTargetFor(c), e = !0; return this.lastElement = d, void 0 === d ? delete this.invalid[c.name] : (this.prepareElement(d), this.currentElements = a(d), e = this.check(d) !== !1, e ? delete this.invalid[d.name] : this.invalid[d.name] = !0), a(b).attr("aria-invalid", !e), this.numberOfInvalids() || (this.toHide = this.toHide.add(this.containers)), this.showErrors(), e }, showErrors: function (b) { if (b) { a.extend(this.errorMap, b), this.errorList = []; for (var c in b) this.errorList.push({ message: b[c], element: this.findByName(c)[0] }); this.successList = a.grep(this.successList, function (a) { return !(a.name in b) }) } this.settings.showErrors ? this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors() }, resetForm: function () { a.fn.resetForm && a(this.currentForm).resetForm(), this.submitted = {}, this.lastElement = null, this.prepareForm(), this.hideErrors(), this.elements().removeClass(this.settings.errorClass).removeData("previousValue").removeAttr("aria-invalid") }, numberOfInvalids: function () { return this.objectLength(this.invalid) }, objectLength: function (a) { var b, c = 0; for (b in a) c++; return c }, hideErrors: function () { this.hideThese(this.toHide) }, hideThese: function (a) { a.not(this.containers).text(""), this.addWrapper(a).hide() }, valid: function () { return 0 === this.size() }, size: function () { return this.errorList.length }, focusInvalid: function () { if (this.settings.focusInvalid) try { a(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus().trigger("focusin") } catch (b) { } }, findLastActive: function () { var b = this.lastActive; return b && 1 === a.grep(this.errorList, function (a) { return a.element.name === b.name }).length && b }, elements: function () { var b = this, c = {}; return a(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function () { return !this.name && b.settings.debug && window.console && console.error("%o has no name assigned", this), this.name in c || !b.objectLength(a(this).rules()) ? !1 : (c[this.name] = !0, !0) }) }, clean: function (b) { return a(b)[0] }, errors: function () { var b = this.settings.errorClass.split(" ").join("."); return a(this.settings.errorElement + "." + b, this.errorContext) }, reset: function () { this.successList = [], this.errorList = [], this.errorMap = {}, this.toShow = a([]), this.toHide = a([]), this.currentElements = a([]) }, prepareForm: function () { this.reset(), this.toHide = this.errors().add(this.containers) }, prepareElement: function (a) { this.reset(), this.toHide = this.errorsFor(a) }, elementValue: function (b) { var c, d = a(b), e = b.type; return "radio" === e || "checkbox" === e ? a("input[name='" + b.name + "']:checked").val() : "number" === e && "undefined" != typeof b.validity ? b.validity.badInput ? !1 : d.val() : (c = d.val(), "string" == typeof c ? c.replace(/\r/g, "") : c) }, check: function (b) { b = this.validationTargetFor(this.clean(b)); var c, d, e, f = a(b).rules(), g = a.map(f, function (a, b) { return b }).length, h = !1, i = this.elementValue(b); for (d in f) { e = { method: d, parameters: f[d] }; try { if (c = a.validator.methods[d].call(this, i, b, e.parameters), "dependency-mismatch" === c && 1 === g) { h = !0; continue } if (h = !1, "pending" === c) return void (this.toHide = this.toHide.not(this.errorsFor(b))); if (!c) return this.formatAndAdd(b, e), !1 } catch (j) { throw this.settings.debug && window.console && console.log("Exception occurred when checking element " + b.id + ", check the '" + e.method + "' method.", j), j } } if (!h) return this.objectLength(f) && this.successList.push(b), !0 }, customDataMessage: function (b, c) { return a(b).data("msg" + c.charAt(0).toUpperCase() + c.substring(1).toLowerCase()) || a(b).data("msg") }, customMessage: function (a, b) { var c = this.settings.messages[a]; return c && (c.constructor === String ? c : c[b]) }, findDefined: function () { for (var a = 0; a < arguments.length; a++) if (void 0 !== arguments[a]) return arguments[a]; return void 0 }, defaultMessage: function (b, c) { return this.findDefined(this.customMessage(b.name, c), this.customDataMessage(b, c), !this.settings.ignoreTitle && b.title || void 0, a.validator.messages[c], "Warning: No message defined for " + b.name + "") }, formatAndAdd: function (b, c) { var d = this.defaultMessage(b, c.method), e = /\$?\{(\d+)\}/g; "function" == typeof d ? d = d.call(this, c.parameters, b) : e.test(d) && (d = a.validator.format(d.replace(e, "{$1}"), c.parameters)), this.errorList.push({ message: d, element: b, method: c.method }), this.errorMap[b.name] = d, this.submitted[b.name] = d }, addWrapper: function (a) { return this.settings.wrapper && (a = a.add(a.parent(this.settings.wrapper))), a }, defaultShowErrors: function () { var a, b, c; for (a = 0; this.errorList[a]; a++) c = this.errorList[a], this.settings.highlight && this.settings.highlight.call(this, c.element, this.settings.errorClass, this.settings.validClass), this.showLabel(c.element, c.message); if (this.errorList.length && (this.toShow = this.toShow.add(this.containers)), this.settings.success) for (a = 0; this.successList[a]; a++) this.showLabel(this.successList[a]); if (this.settings.unhighlight) for (a = 0, b = this.validElements() ; b[a]; a++) this.settings.unhighlight.call(this, b[a], this.settings.errorClass, this.settings.validClass); this.toHide = this.toHide.not(this.toShow), this.hideErrors(), this.addWrapper(this.toShow).show() }, validElements: function () { return this.currentElements.not(this.invalidElements()) }, invalidElements: function () { return a(this.errorList).map(function () { return this.element }) }, showLabel: function (b, c) { var d, e, f, g = this.errorsFor(b), h = this.idOrName(b), i = a(b).attr("aria-describedby"); g.length ? (g.removeClass(this.settings.validClass).addClass(this.settings.errorClass), g.html(c)) : (g = a("<" + this.settings.errorElement + ">").attr("id", h + "-error").addClass(this.settings.errorClass).html(c || ""), d = g, this.settings.wrapper && (d = g.hide().show().wrap("<" + this.settings.wrapper + "/>").parent()), this.labelContainer.length ? this.labelContainer.append(d) : this.settings.errorPlacement ? this.settings.errorPlacement(d, a(b)) : d.insertAfter(b), g.is("label") ? g.attr("for", h) : 0 === g.parents("label[for='" + h + "']").length && (f = g.attr("id"), i ? i.match(new RegExp("\b" + f + "\b")) || (i += " " + f) : i = f, a(b).attr("aria-describedby", i), e = this.groups[b.name], e && a.each(this.groups, function (b, c) { c === e && a("[name='" + b + "']", this.currentForm).attr("aria-describedby", g.attr("id")) }))), !c && this.settings.success && (g.text(""), "string" == typeof this.settings.success ? g.addClass(this.settings.success) : this.settings.success(g, b)), this.toShow = this.toShow.add(g) }, errorsFor: function (b) { var c = this.idOrName(b), d = a(b).attr("aria-describedby"), e = "label[for='" + c + "'], label[for='" + c + "'] *"; return d && (e = e + ", #" + d.replace(/\s+/g, ", #")), this.errors().filter(e) }, idOrName: function (a) { return this.groups[a.name] || (this.checkable(a) ? a.name : a.id || a.name) }, validationTargetFor: function (a) { return this.checkable(a) && (a = this.findByName(a.name).not(this.settings.ignore)[0]), a }, checkable: function (a) { return /radio|checkbox/i.test(a.type) }, findByName: function (b) { return a(this.currentForm).find("[name='" + b + "']") }, getLength: function (b, c) { switch (c.nodeName.toLowerCase()) { case "select": return a("option:selected", c).length; case "input": if (this.checkable(c)) return this.findByName(c.name).filter(":checked").length } return b.length }, depend: function (a, b) { return this.dependTypes[typeof a] ? this.dependTypes[typeof a](a, b) : !0 }, dependTypes: { "boolean": function (a) { return a }, string: function (b, c) { return !!a(b, c.form).length }, "function": function (a, b) { return a(b) } }, optional: function (b) { var c = this.elementValue(b); return !a.validator.methods.required.call(this, c, b) && "dependency-mismatch" }, startRequest: function (a) { this.pending[a.name] || (this.pendingRequest++, this.pending[a.name] = !0) }, stopRequest: function (b, c) { this.pendingRequest--, this.pendingRequest < 0 && (this.pendingRequest = 0), delete this.pending[b.name], c && 0 === this.pendingRequest && this.formSubmitted && this.form() ? (a(this.currentForm).submit(), this.formSubmitted = !1) : !c && 0 === this.pendingRequest && this.formSubmitted && (a(this.currentForm).triggerHandler("invalid-form", [this]), this.formSubmitted = !1) }, previousValue: function (b) { return a.data(b, "previousValue") || a.data(b, "previousValue", { old: null, valid: !0, message: this.defaultMessage(b, "remote") }) } }, classRuleSettings: { required: { required: !0 }, email: { email: !0 }, url: { url: !0 }, date: { date: !0 }, dateISO: { dateISO: !0 }, number: { number: !0 }, digits: { digits: !0 }, creditcard: { creditcard: !0 } }, addClassRules: function (b, c) { b.constructor === String ? this.classRuleSettings[b] = c : a.extend(this.classRuleSettings, b) }, classRules: function (b) { var c = {}, d = a(b).attr("class"); return d && a.each(d.split(" "), function () { this in a.validator.classRuleSettings && a.extend(c, a.validator.classRuleSettings[this]) }), c }, attributeRules: function (b) { var c, d, e = {}, f = a(b), g = b.getAttribute("type"); for (c in a.validator.methods) "required" === c ? (d = b.getAttribute(c), "" === d && (d = !0), d = !!d) : d = f.attr(c), /min|max/.test(c) && (null === g || /number|range|text/.test(g)) && (d = Number(d)), d || 0 === d ? e[c] = d : g === c && "range" !== g && (e[c] = !0); return e.maxlength && /-1|2147483647|524288/.test(e.maxlength) && delete e.maxlength, e }, dataRules: function (b) { var c, d, e = {}, f = a(b); for (c in a.validator.methods) d = f.data("rule" + c.charAt(0).toUpperCase() + c.substring(1).toLowerCase()), void 0 !== d && (e[c] = d); return e }, staticRules: function (b) { var c = {}, d = a.data(b.form, "validator"); return d.settings.rules && (c = a.validator.normalizeRule(d.settings.rules[b.name]) || {}), c }, normalizeRules: function (b, c) { return a.each(b, function (d, e) { if (e === !1) return void delete b[d]; if (e.param || e.depends) { var f = !0; switch (typeof e.depends) { case "string": f = !!a(e.depends, c.form).length; break; case "function": f = e.depends.call(c, c) } f ? b[d] = void 0 !== e.param ? e.param : !0 : delete b[d] } }), a.each(b, function (d, e) { b[d] = a.isFunction(e) ? e(c) : e }), a.each(["minlength", "maxlength"], function () { b[this] && (b[this] = Number(b[this])) }), a.each(["rangelength", "range"], function () { var c; b[this] && (a.isArray(b[this]) ? b[this] = [Number(b[this][0]), Number(b[this][1])] : "string" == typeof b[this] && (c = b[this].replace(/[\[\]]/g, "").split(/[\s,]+/), b[this] = [Number(c[0]), Number(c[1])])) }), a.validator.autoCreateRanges && (b.min && b.max && (b.range = [b.min, b.max], delete b.min, delete b.max), b.minlength && b.maxlength && (b.rangelength = [b.minlength, b.maxlength], delete b.minlength, delete b.maxlength)), b }, normalizeRule: function (b) { if ("string" == typeof b) { var c = {}; a.each(b.split(/\s/), function () { c[this] = !0 }), b = c } return b }, addMethod: function (b, c, d) { a.validator.methods[b] = c, a.validator.messages[b] = void 0 !== d ? d : a.validator.messages[b], c.length < 3 && a.validator.addClassRules(b, a.validator.normalizeRule(b)) }, methods: { required: function (b, c, d) { if (!this.depend(d, c)) return "dependency-mismatch"; if ("select" === c.nodeName.toLowerCase()) { var e = a(c).val(); return e && e.length > 0 } return this.checkable(c) ? this.getLength(b, c) > 0 : a.trim(b).length > 0 }, email: function (a, b) { return this.optional(b) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a) }, url: function (a, b) { return this.optional(b) || /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a) }, date: function (a, b) { return this.optional(b) || !/Invalid|NaN/.test(new Date(a).toString()) }, dateISO: function (a, b) { return this.optional(b) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a) }, number: function (a, b) { return this.optional(b) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a) }, digits: function (a, b) { return this.optional(b) || /^\d+$/.test(a) }, creditcard: function (a, b) { if (this.optional(b)) return "dependency-mismatch"; if (/[^0-9 \-]+/.test(a)) return !1; var c, d, e = 0, f = 0, g = !1; if (a = a.replace(/\D/g, ""), a.length < 13 || a.length > 19) return !1; for (c = a.length - 1; c >= 0; c--) d = a.charAt(c), f = parseInt(d, 10), g && (f *= 2) > 9 && (f -= 9), e += f, g = !g; return e % 10 === 0 }, minlength: function (b, c, d) { var e = a.isArray(b) ? b.length : this.getLength(a.trim(b), c); return this.optional(c) || e >= d }, maxlength: function (b, c, d) { var e = a.isArray(b) ? b.length : this.getLength(a.trim(b), c); return this.optional(c) || d >= e }, rangelength: function (b, c, d) { var e = a.isArray(b) ? b.length : this.getLength(a.trim(b), c); return this.optional(c) || e >= d[0] && e <= d[1] }, min: function (a, b, c) { return this.optional(b) || a >= c }, max: function (a, b, c) { return this.optional(b) || c >= a }, range: function (a, b, c) { return this.optional(b) || a >= c[0] && a <= c[1] }, equalTo: function (b, c, d) { var e = a(d); return this.settings.onfocusout && e.unbind(".validate-equalTo").bind("blur.validate-equalTo", function () { a(c).valid() }), b === e.val() }, remote: function (b, c, d) { if (this.optional(c)) return "dependency-mismatch"; var e, f, g = this.previousValue(c); return this.settings.messages[c.name] || (this.settings.messages[c.name] = {}), g.originalMessage = this.settings.messages[c.name].remote, this.settings.messages[c.name].remote = g.message, d = "string" == typeof d && { url: d } || d, g.old === b ? g.valid : (g.old = b, e = this, this.startRequest(c), f = {}, f[c.name] = b, a.ajax(a.extend(!0, { url: d, mode: "abort", port: "validate" + c.name, dataType: "json", data: f, context: e.currentForm, success: function (d) { var f, h, i, j = d === !0 || "true" === d; e.settings.messages[c.name].remote = g.originalMessage, j ? (i = e.formSubmitted, e.prepareElement(c), e.formSubmitted = i, e.successList.push(c), delete e.invalid[c.name], e.showErrors()) : (f = {}, h = d || e.defaultMessage(c, "remote"), f[c.name] = g.message = a.isFunction(h) ? h(b) : h, e.invalid[c.name] = !0, e.showErrors(f)), g.valid = j, e.stopRequest(c, j) } }, d)), "pending") } } }), a.format = function () { throw "$.format has been deprecated. Please use $.validator.format instead." }; var b, c = {}; a.ajaxPrefilter ? a.ajaxPrefilter(function (a, b, d) { var e = a.port; "abort" === a.mode && (c[e] && c[e].abort(), c[e] = d) }) : (b = a.ajax, a.ajax = function (d) { var e = ("mode" in d ? d : a.ajaxSettings).mode, f = ("port" in d ? d : a.ajaxSettings).port; return "abort" === e ? (c[f] && c[f].abort(), c[f] = b.apply(this, arguments), c[f]) : b.apply(this, arguments) }), a.extend(a.fn, { validateDelegate: function (b, c, d) { return this.bind(c, function (c) { var e = a(c.target); return e.is(b) ? d.apply(e, arguments) : void 0 }) } }) });
//wait until fonts are loaded (BASED on http://www.html5gamedevs.com/topic/2385-how-to-make-sure-that-a-font-is-loaded/. many changes.)
function WebFontLoaded(fonts, callback) {
//console.time("WebFontLoaded");
console.time("FontsLoaded");
if (!(fonts instanceof Array)) {
fonts = [fonts];
}
var random = "giItT1WQy@!-/#"; // random characters that usually differ in width depending on the font
//DZ 29may17: seems like sans-serif shares exact widths with arimoregular & texgryters
var fallbackFontName = "monospace"; //"sans-serif"
for (var i = 0; i < fonts.length; i++) {
var span = $('').text(random).css({
"font-family": fallbackFontName,
"font-variant": "normal",
"font-style": "normal",
"font-weight": "normal",
"font-size": "50px",
"letter-spacing": "0",
"position": "absolute",
"left": "-2000px",
"top": "-2000px",
"width":"auto"
}).addClass('temp_font_loading');
$('body').append(span);
span.attr('oldWidth', span.outerWidth());
//loader.push([span, span.outerWidth()]);
span.css("font-family", fonts[i] + ',' + fallbackFontName); //sans-serif'); //DZ: adde fallback to default font
}
var timesTested = 0;
var interval = setInterval(function () {
var temp_font_spans = $('body > .temp_font_loading');
temp_font_spans.each(function () {
var oldWidth = parseFloat($(this).attr('oldWidth'));
var nowWidth = $(this).outerWidth();
var nowFont = $(this).css('font-family').replace(',' + fallbackFontName,'');
if (oldWidth == nowWidth) {
debug.warn('font "' + nowFont + '" not loaded. ' + nowWidth + '==' + oldWidth);
}
else
{
debug.log('font "' + nowFont + '" LOADED. ' + nowWidth + '!=' + oldWidth);
$(this).remove();
}
});
timesTested++;
if (temp_font_spans.length == 0)
{
clearInterval(interval);
console.log('=== all fonts loaded ===');
console.timeEnd("FontsLoaded");
callback();
}
else
{
if (timesTested>30)
{
clearInterval(interval);
//alert('WARNING: waited too long for fonts to load. some fonts might be missing');
console.error('WARNING: waited too long for fonts to load. some fonts might be missing', temp_font_spans);
console.timeEnd("FontsLoaded");
callback();
}
}
}, 50);
};
//-------- Safari iOS ratio fix for image rescaling:
//https://github.com/stomita/ios-imagefile-megapixel/
/**
* Mega pixel image rendering library for iOS6 Safari
*
* Fixes iOS6 Safari's image file rendering issue for large size image (over mega-pixel),
* which causes unexpected subsampling when drawing it in canvas.
* By using this library, you can safely render the image with proper stretching.
*
* Copyright (c) 2012 Shinichi Tomita
* Released under the MIT license
*/
(function () { function e(e) { var t = e.naturalWidth, n = e.naturalHeight; if (t * n > 1024 * 1024) { var r = document.createElement("canvas"); r.width = r.height = 1; var i = r.getContext("2d"); i.drawImage(e, -t + 1, 0); return i.getImageData(0, 0, 1, 1).data[3] === 0 } else { return false } } function t(e, t, n) { var r = document.createElement("canvas"); r.width = 1; r.height = n; var i = r.getContext("2d"); i.drawImage(e, 0, 0); var s = i.getImageData(0, 0, 1, n).data; var o = 0; var u = n; var a = n; while (a > o) { var f = s[(a - 1) * 4 + 3]; if (f === 0) { u = a } else { o = a } a = u + o >> 1 } var l = a / n; return l === 0 ? 1 : l } function n(e, t, n) { var i = document.createElement("canvas"); r(e, i, t, n); return i.toDataURL("image/jpeg", t.quality || .8) } function r(n, r, s, o) { var u = n.naturalWidth, a = n.naturalHeight; var f = s.width, l = s.height; var c = r.getContext("2d"); c.save(); i(r, c, f, l, s.orientation); var h = e(n); if (h) { u /= 2; a /= 2 } var p = 1024; var d = document.createElement("canvas"); d.width = d.height = p; var v = d.getContext("2d"); var m = o ? t(n, u, a) : 1; var g = Math.ceil(p * f / u); var y = Math.ceil(p * l / a / m); var b = 0; var w = 0; while (b < a) { var E = 0; var S = 0; while (E < u) { v.clearRect(0, 0, p, p); v.drawImage(n, -E, -b); c.drawImage(d, 0, 0, p, p, S, w, g, y); E += p; S += g } b += p; w += y } c.restore(); d = v = null } function i(e, t, n, r, i) { switch (i) { case 5: case 6: case 7: case 8: e.width = r; e.height = n; break; default: e.width = n; e.height = r } switch (i) { case 2: t.translate(n, 0); t.scale(-1, 1); break; case 3: t.translate(n, r); t.rotate(Math.PI); break; case 4: t.translate(0, r); t.scale(1, -1); break; case 5: t.rotate(.5 * Math.PI); t.scale(1, -1); break; case 6: t.rotate(.5 * Math.PI); t.translate(0, -r); break; case 7: t.rotate(.5 * Math.PI); t.translate(n, -r); t.scale(-1, 1); break; case 8: t.rotate(-.5 * Math.PI); t.translate(-n, 0); break; default: break } } function s(e) { if (window.Blob && e instanceof Blob) { var t = new Image; var n = window.URL && window.URL.createObjectURL ? window.URL : window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL : null; if (!n) { throw Error("No createObjectURL function found to create blob url") } t.src = n.createObjectURL(e); this.blob = e; e = t } if (!e.naturalWidth && !e.naturalHeight) { var r = this; e.onload = function () { var e = r.imageLoadListeners; if (e) { r.imageLoadListeners = null; for (var t = 0, n = e.length; t < n; t++) { e[t]() } } }; this.imageLoadListeners = [] } this.srcImage = e } s.prototype.render = function (e, t) { if (this.imageLoadListeners) { var i = this; this.imageLoadListeners.push(function () { i.render(e, t) }); return } t = t || {}; var s = this.srcImage.naturalWidth, o = this.srcImage.naturalHeight, u = t.width, a = t.height, f = t.maxWidth, l = t.maxHeight, c = !this.blob || this.blob.type === "image/jpeg"; if (u && !a) { a = o * u / s << 0 } else if (a && !u) { u = s * a / o << 0 } else { u = s; a = o } if (f && u > f) { u = f; a = o * u / s << 0 } if (l && a > l) { a = l; u = s * a / o << 0 } var h = { width: u, height: a }; for (var p in t) h[p] = t[p]; var d = e.tagName.toLowerCase(); if (d === "img") { e.src = n(this.srcImage, h, c) } else if (d === "canvas") { r(this.srcImage, e, h, c) } if (typeof this.onrender === "function") { this.onrender(e) } }; if (typeof define === "function" && define.amd) { define([], function () { return s }) } else { this.MegaPixImage = s } })()
//DZ 8may17: updated to version 1.3.2, from something quite old
//FileSaver: https://github.com/eligrey/FileSaver.js
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs = saveAs || function (e) { "use strict"; if (typeof e === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { return } var t = e.document, n = function () { return e.URL || e.webkitURL || e }, r = t.createElementNS("..\\http\\www.w3.org\\1999\\MS_7795.html", "a"), o = "download" in r, a = function (e) { var t = new MouseEvent("click"); e.dispatchEvent(t) }, i = /constructor/i.test(e.HTMLElement) || e.safari, f = /CriOS\/[\d]+/.test(navigator.userAgent), u = function (t) { (e.setImmediate || e.setTimeout)(function () { throw t }, 0) }, s = "application/octet-stream", d = 1e3 * 40, c = function (e) { var t = function () { if (typeof e === "string") { n().revokeObjectURL(e) } else { e.remove() } }; setTimeout(t, d) }, l = function (e, t, n) { t = [].concat(t); var r = t.length; while (r--) { var o = e["on" + t[r]]; if (typeof o === "function") { try { o.call(e, n || e) } catch (a) { u(a) } } } }, p = function (e) { if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)) { return new Blob([String.fromCharCode(65279), e], { type: e.type }) } return e }, v = function (t, u, d) { if (!d) { t = p(t) } var v = this, w = t.type, m = w === s, y, h = function () { l(v, "writestart progress write writeend".split(" ")) }, S = function () { if ((f || m && i) && e.FileReader) { var r = new FileReader; r.onloadend = function () { var t = f ? r.result : r.result.replace(/^data:[^;]*;/, "data:attachment/file;"); var n = e.open(t, "_blank"); if (!n) e.location.href = t; t = undefined; v.readyState = v.DONE; h() }; r.readAsDataURL(t); v.readyState = v.INIT; return } if (!y) { y = n().createObjectURL(t) } if (m) { e.location.href = y } else { var o = e.open(y, "_blank"); if (!o) { e.location.href = y } } v.readyState = v.DONE; h(); c(y) }; v.readyState = v.INIT; if (o) { y = n().createObjectURL(t); setTimeout(function () { r.href = y; r.download = u; a(r); h(); c(y); v.readyState = v.DONE }); return } S() }, w = v.prototype, m = function (e, t, n) { return new v(e, t || e.name || "download", n) }; if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { return function (e, t, n) { t = t || e.name || "download"; if (!n) { e = p(e) } return navigator.msSaveOrOpenBlob(e, t) } } w.abort = function () { }; w.readyState = w.INIT = 0; w.WRITING = 1; w.DONE = 2; w.error = w.onwritestart = w.onprogress = w.onwrite = w.onabort = w.onerror = w.onwriteend = null; return m }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content); if (typeof module !== "undefined" && module.exports) { module.exports.saveAs = saveAs } else if (typeof define !== "undefined" && define !== null && define.amd !== null) { define("FileSaver.js", function () { return saveAs }) }
//DZ 8may17: updated to newest version (2 years ago) - not sure anything was changed
//blob.js - minified, https://github.com/eligrey/Blob.js/blob/master/Blob.js
//a dependency for FileSaver, required for Safari support
!function (a) { "use strict"; if (a.URL = a.URL || a.webkitURL, a.Blob && a.URL) try { return void new Blob } catch (a) { } var b = a.BlobBuilder || a.WebKitBlobBuilder || a.MozBlobBuilder || function (a) { var b = function (a) { return Object.prototype.toString.call(a).match(/^\[object\s(.*)\]$/)[1] }, c = function () { this.data = [] }, d = function (b, c, d) { this.data = b, this.size = b.length, this.type = c, this.encoding = d }, e = c.prototype, f = d.prototype, g = a.FileReaderSync, h = function (a) { this.code = this[this.name = a] }, i = "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "), j = i.length, k = a.URL || a.webkitURL || a, l = k.createObjectURL, m = k.revokeObjectURL, n = k, o = a.btoa, p = a.atob, q = a.ArrayBuffer, r = a.Uint8Array, s = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/; for (d.fake = f.fake = !0; j--;) h.prototype[i[j]] = j + 1; return k.createObjectURL || (n = a.URL = function (a) { var c, b = document.createElementNS("..\\http\\www.w3.org\\1999\\MS_7795.html", "a"); return b.href = a, "origin" in b || ("data:" === b.protocol.toLowerCase() ? b.origin = null : (c = a.match(s), b.origin = c && c[1])), b }), n.createObjectURL = function (a) { var c, b = a.type; return null === b && (b = "application/octet-stream"), a instanceof d ? (c = "data:" + b, "base64" === a.encoding ? c + ";base64," + a.data : "URI" === a.encoding ? c + "," + decodeURIComponent(a.data) : o ? c + ";base64," + o(a.data) : c + "," + encodeURIComponent(a.data)) : l ? l.call(k, a) : void 0 }, n.revokeObjectURL = function (a) { "data:" !== a.substring(0, 5) && m && m.call(k, a) }, e.append = function (a) { var c = this.data; if (r && (a instanceof q || a instanceof r)) { for (var e = "", f = new r(a), i = 0, j = f.length; i < j; i++) e += String.fromCharCode(f[i]); c.push(e) } else if ("Blob" === b(a) || "File" === b(a)) { if (!g) throw new h("NOT_READABLE_ERR"); var k = new g; c.push(k.readAsBinaryString(a)) } else a instanceof d ? "base64" === a.encoding && p ? c.push(p(a.data)) : "URI" === a.encoding ? c.push(decodeURIComponent(a.data)) : "raw" === a.encoding && c.push(a.data) : ("string" != typeof a && (a += ""), c.push(unescape(encodeURIComponent(a)))) }, e.getBlob = function (a) { return arguments.length || (a = null), new d(this.data.join(""), a, "raw") }, e.toString = function () { return "[object BlobBuilder]" }, f.slice = function (a, b, c) { var e = arguments.length; return e < 3 && (c = null), new d(this.data.slice(a, e > 1 ? b : this.data.length), c, this.encoding) }, f.toString = function () { return "[object Blob]" }, f.close = function () { this.size = 0, delete this.data }, c }(a); a.Blob = function (a, c) { var d = c ? c.type || "" : "", e = new b; if (a) for (var f = 0, g = a.length; f < g; f++) Uint8Array && a[f] instanceof Uint8Array ? e.append(a[f].buffer) : e.append(a[f]); var h = e.getBlob(d); return !h.slice && h.webkitSlice && (h.slice = h.webkitSlice), h }; var c = Object.getPrototypeOf || function (a) { return a.__proto__ }; a.Blob.prototype = c(new a.Blob) }("undefined" != typeof self && self || "undefined" != typeof window && window || this.content || this);
//base64 image to blob:
//adapted from "Optimized" comment in : http://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascripts
function base64toBlob(base64Data, contentType) {
contentType = contentType || '';
var sliceSize = 1024;
var byteCharacters = atob(base64Data);
var bytesLength = byteCharacters.length;
var slicesCount = Math.ceil(bytesLength / sliceSize);
var byteArrays = new Array(slicesCount);
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
var begin = sliceIndex * sliceSize;
var end = Math.min(begin + sliceSize, bytesLength);
var bytes = new Array(end - begin);
for (var offset = begin, i = 0 ; offset < end; ++i, ++offset) {
bytes[i] = byteCharacters[offset].charCodeAt(0);
}
byteArrays[sliceIndex] = new Uint8Array(bytes);
}
return new Blob(byteArrays, { type: contentType });
}
//PRICE ROUND:
function precise_round(num, decimals) {
var ret = num;
try
{
ret = Math.round(ret);
}
catch(e)
{
//TODO: IE fails on above function. FIX IT
}
return ret;
}
//PUBSUB:
/*! Tiny Pub/Sub - v0.7.0 - 2013-01-29
* https://github.com/cowboy/jquery-tiny-pubsub
* Copyright (c) 2013 "Cowboy" Ben Alman; Licensed MIT */
(function ($) {
var o = $({});
$.subscribe = function () {
o.on.apply(o, arguments);
};
$.unsubscribe = function () {
o.off.apply(o, arguments);
};
$.publish = function () {
o.trigger.apply(o, arguments);
};
}(jQuery));
//DZ 16jun15: global dictionary for client-side localization helper
function getLocCaption(key)
{
if (key in localizationDict)
return localizationDict[key];
else
{
console.warn("Localization key '" + key + "' not found");
return key;
}
}
//YZ 28/1/19 - adding same version of imgUrlToBase64 only that returns a promise.
//YZ 17/3/19 - checking the filetype and calling the different imgToBase64 method for png - to preserve png transperancy
function imgUrlToBase64_(imgUrl) {
var dfd = jQuery.Deferred();
async_create_and_load_image(imgUrl, function (imgObj) {
var isPng = imgObj.src !== "undefined" && imgObj.src.toLowerCase().indexOf(".png\\.png") >= 1;
var b64img = isPng ? imgToBase64_png(imgObj) : imgToBase64(imgObj);
if (b64img !== null) {
dfd.resolve(b64img);
}
else
{
dfd.reject();
}
});
return dfd.promise();
}
function imgUrlToBase64(imgUrl,succFunc)
{
async_create_and_load_image(imgUrl, function (imgObj) {
var b64img = imgToBase64(imgObj);
succFunc(b64img);
});
}
function imgToBase64(imgObj)
{
var canvas = document.createElement('CANVAS');
var ctx = canvas.getContext('2d');
canvas.height = imgObj.height;
canvas.width = imgObj.width;
ctx.drawImage(imgObj, 0, 0);
var dataURL = canvas.toDataURL("image/jpeg", toDataUrlQuality);
canvas = null;
return dataURL;
}
//DZ 17jul18: used in custom stickers
function imgToBase64_png(imgObj) {
var canvas = document.createElement('CANVAS');
var ctx = canvas.getContext('2d');
canvas.height = imgObj.height;
canvas.width = imgObj.width;
ctx.drawImage(imgObj, 0, 0);
var dataURL = canvas.toDataURL("image/png");
canvas = null;
return dataURL;
}
//returns e.g. "7.0.2" - adapted from http://stackoverflow.com/questions/7184573/pick-up-the-android-version-in-the-browser-by-javascript
function getAndroidVersion(ua) {
ua = (ua || navigator.userAgent).toLowerCase();
var match = ua.match(/android\s([0-9\.]*)/);
return match ? match[1] : false;
};;
//GI Print & Render Logic
//---------------------------------------------------------------------------------------
//YZ 01oct15 : changing value from 1 to 0.99
//var toDataUrlQuality = 0.99; //1; //from 0 to 1, default is around 0.92
var toDataUrlQuality = Number(getParameterByName('quality') === '' ? 0.99 : getParameterByName('quality'));
//utils:
function shouldApplyOutputCanvasSizeCheck() {
var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
var isIE9 = sayswho() == "MSIE 9";
var isIE10 = sayswho() == "MSIE 10";
return isIE || isIE9 || isIE10;
}
//many times we do Img.onload={}; Img.src = '...' - this util makes it readable, and fixes shit-load of issues
//NOTICE: duplicated on 27jan16 on filter_helper.html and on new_edit.render.js
function async_create_and_load_image(imgSrc, succFunc) {
if (succFunc == null) {
debug.error("NULL SUCC-FUNC");
}
var logged_img_src = (imgSrc != null && imgSrc.length > 150) ? imgSrc.substring(0, 150) : imgSrc;
//short history:
//DZ 18mar15: this was added for s3 images
//DZ 13may15: this caused issues for stickers in Safari Mac. so removed usage for base64 images
//DZ 18may15: removed totally, caused issues with filters in Safari Mac
//DZ 15jun15: does cause issues with s3 images... needs to be fixed.
//DZ 16jun15: returning this one, so it will work with saved images
//if (imgSrc[0] !== 'd' && imgSrc.lastIndexOf('dataimage\\MS_7792.html', 0) < 0)
// jsImage.crossOrigin = "Anonymous";
//DZ: 21jun15: returned. must have for CORS from s3 (saved cards)
//in Chrome, working for UPLOADED SAVED IMAGES if anonymous is here,
//in Safari, WORKING for UPLOADED IMAGES (rotation, filters) if anonymous is missing here
var jsImage = new Image();
if (imgSrc[0] !== 'd' && imgSrc.lastIndexOf('dataimage\\MS_7792.html', 0) < 0) {
//DZ 14mar18: fixes issues with URLS with spaces failing on SAM.
//e.g for such card: filename "New-Era white.png" in invitation "New Era" (id #11806)
//this issue never happened (in years) in website variation - so just in case we dont apply fix outside of SAM
if (editorAppMode==='SAM'){
imgSrc = encodeURI(imgSrc);
//logged_img_src = imgSrc;
}
debug.log('ASYNC LOAD will be anon', logged_img_src);
jsImage.crossOrigin = "Anonymous";
//DZ 24sep15: fix for IE9/IE10 (
var isIE9 = sayswho() == "MSIE 9";
var isIE10 = sayswho() == "MSIE 10";
//DZ 30sep15: proxy fix shoudlnt be applied for onsite images
//DZ 20jan16: ms edge detection
var isEdge = (/Edge./i.test(navigator.userAgent));
//DZ 26jan16: adding safari to CORS fix... used to work before. maybe browser update, maybe bucket policy change (?)
var isSafari = (sayswho().toLowerCase().indexOf("safari") >= 0);
if (imgSrc[0] !== '..\\index.html' && (isIE9 || isIE10 || isEdge || isSafari)) {
//if (isIE9 || isIE10) {
//DZ 11mar18: SAM code merge
//DZ (SAM) 3dec17: no more proxy solution here!
if (editorAppMode === "SAM")
debug.warn("SAM - USED TO HAVE IE9/10 proxy kobmina", imgSrc);
else
{
imgSrc = "..\\MS_59.html?url=" + imgSrc;
debug.log("IE9/10 proxy kobmina", imgSrc);
}
}
//}
}
else
debug.log('ASYNC LOAD will not be anon', logged_img_src);
jsImage.onload = function () {
jsImage.onload = null;
debug.log("ASYNC LOAD SUCCESS", logged_img_src);
succFunc(jsImage);
};
//DZ 22jan15:
jsImage.onerror = function (err) {
//DZ 11mar18: minor fix for logging:
//debug.error("ASYNC LOAD FAILED. trying to ignore", logged_img_src);
console.error("ASYNC LOAD FAILED. trying to ignore", logged_img_src, err);
succFunc(null);
};
jsImage.src = imgSrc;
}
//---------------------------------------------------------------------------------------
// RENDER METHODS
//---------------------------------------------------------------------------------------
//new version 27jul14:
//DZ 11nov15: added renderMode for special modes, used for marginTextDetection
//renderModes:
//null - normal, succFunc returns rendered canvas
//marginTextDetection - renders only textslots, succFunc returns null if no text at borders, and the relevant jqSlot if it does
function render_canvas_from_frame(jqFrame, targetWidth, targetHeight, renderMode, succFunc) {
//console.log("==== FROM METHOD 7777 ==", get_rotation_degress_of_element($('.slot_text:first')));
if (succFunc == null) {
debug.error("NULL SUCC-FUNC");
}
console.log('=== rendering canvas to ' + targetWidth + 'x' + targetHeight + 'px ===', jqFrame);
//DZ 18aug14: forcing vis only if now invis + not messing out display (showing absolute far away)
////jqFrame.parents('.editorTab').addClass('forceVisible');
var wasForcedVisible = false;
if (!jqFrame.parents('.editorTab').hasClass('active')) {
wasForcedVisible = true;
jqFrame.parents('.editorTab').addClass('forceVisible');
//DZ: 1oct14: using same line from change_editor_tab before printing. otherwise we wad rare text offsets moving around
desLogic.reinit_autosizer($('.slot_text:visible textarea.custom_textarea:visible'));
}
var newCanvas = document.createElement('canvas');
newCanvas.width = targetWidth;
newCanvas.height = targetHeight;
var ctx = newCanvas.getContext("2d");
//background color=white
ctx.fillStyle = '#FFFFFF'; // set canvas background color
ctx.fillRect(0, 0, targetWidth, targetHeight); // now fill the canvas
//all relevant decors:
var all_card_decors = jqFrame.find(".card_decor:visible").toArray();
var decors_that_failed_border_test = [];
var final_func = function () {
if (wasForcedVisible) {
jqFrame.parents('.editorTab').removeClass('forceVisible');
}
if (renderMode == null) {
debug.log('=== DONE rendering canvas (' + newCanvas.width + 'x' + newCanvas.height + ') ===');
succFunc(newCanvas);
}
else if (renderMode == "marginTextDetection") {
if (decors_that_failed_border_test == null || decors_that_failed_border_test.length == 0)
debug.log('=== DONE rendering canvas for border check - All OK (' + newCanvas.width + 'x' + newCanvas.height + ') ===');
else
debug.log('=== DONE rendering canvas for border check - 1 failed (' + newCanvas.width + 'x' + newCanvas.height + ') ===', decors_that_failed_border_test);
succFunc(decors_that_failed_border_test);
}
}
if (all_card_decors.length == 0) {
final_func();
}
else {
//order everything by z-index:
all_card_decors.sort(function (a, b) {
//debug.log(Number(a.style.zIndex), Number(b.style.zIndex));
//return (Number(a.style.zIndex) - Number(b.style.zIndex));
//debug.log($(a).zIndex(), $(b).zIndex());
//DZ 9apr17: might be dangerous change, zIndex stopped working on mobile (? jQuery-ui version ?) - changing to css(zindex):
//return ($(a).zIndex() - $(b).zIndex());
//DZ 11mar18: the below code didnt exist in SAM version - should be alright tho
//DZ 26oct17: CIE-246: because of CSS rules below, we mess with the "right" z-indexes, so we manually fix 'em now:
//affecting CSS rules:
///* when showing editor showing big picture overlay BELOW images, to be able to align correctly */
//.decor_full_image {
// z-index: 10;
//}
///* returning to normal z-index when renderding */
//.forceVisible .decor_full_image {
// z-index: 20;
//}
//old code:
//var az = isNaN($(a).css('z-index')) ? 0 : parseInt($(a).css('z-index'));
//var bz = isNaN($(b).css('z-index')) ? 0 : parseInt($(b).css('z-index'));
//new (26oct17) code:
var getSortVal = function (elm) {
if ($(elm).hasClass('decor_full_image'))
return 10;
else
return isNaN($(elm).css('z-index')) ? 0 : parseInt($(elm).css('z-index'));
};
var az = getSortVal(a);
var bz = getSortVal(b);
//console.log("TEST", az, bz, a,b);
return az - bz;
});
//forcing one-by-one rendering of each async decor render
var recursive_sync_render_func = function (curr_idx) {
if (curr_idx < all_card_decors.length) {
//NORMAL MODE
if (renderMode == null) {
debug.log('--- render decor ' + curr_idx + '..\\index.html' + (all_card_decors.length - 1));
render_decor_to_canvas_ctx(jqFrame, $(all_card_decors[curr_idx]), ctx, targetWidth, targetHeight, renderMode, function () {
//RECURSIVE CALL
recursive_sync_render_func(curr_idx + 1);
});
}
//MARGIN DETECTION MODE
else if (renderMode === "marginTextDetection") {
var currentDecor = $(all_card_decors[curr_idx]);
if (!currentDecor.hasClass('slot_text')) {
//skipping non-text decors
debug.log("decor skipped");
//RECURSIVE CALL
recursive_sync_render_func(curr_idx + 1);
}
else {
debug.log('--- render decor ' + curr_idx + '..\\index.html' + (all_card_decors.length - 1));
render_decor_to_canvas_ctx(jqFrame, currentDecor, ctx, targetWidth, targetHeight, renderMode, function () {
//after text slot rendered, we check if it exists
//invitation is 5"x7" or 5"x5", border is 0.15" each side
var safeBorderPixels;
if (getLayout() == "square")
//width is 5", border pixels is 0.15"
safeBorderPixels = (0.15 / 5 * targetWidth)
else if (getLayout() == "landscape")
//height is 5", border pixels is 0.15"
safeBorderPixels = (0.15 / 5 * targetHeight)
else //portrait
//width is 5", border pixels is 0.15"
safeBorderPixels = (0.15 / 5 * targetWidth)
safeBorderPixels = parseInt(safeBorderPixels);
debug.log("safeBorderPixels calculated to ", safeBorderPixels);
var currentDecorIsSafe = checkCanvasForMargins(ctx, targetWidth, targetHeight, safeBorderPixels);
if (!currentDecorIsSafe)
decors_that_failed_border_test.push(currentDecor);
//RESET THE CANVAS NOW - to test next textslot:
ctx.fillStyle = '#FFFFFF'; // set canvas background color
ctx.fillRect(0, 0, targetWidth, targetHeight); // now fill the canvas
//RECURSIVE CALL to next item
recursive_sync_render_func(curr_idx + 1);
});
}
}
}
else {
//END CONDITION:
final_func();
}
}
recursive_sync_render_func(0);
}
}
//succFunc here doesnt have a return value (function param)
function render_decor_to_canvas_ctx(jqFrame, thisDecor, ctx, targetWidth, targetHeight, renderMode, succFunc) {
if (succFunc == null) {
debug.error("NULL SUCC-FUNC");
}
var originalWidth = jqFrame.width();
var originalHeight = jqFrame.height();
var innerDecor = thisDecor;
if (thisDecor.hasClass('sticker_container'))
innerDecor = thisDecor.find('img'); //to compensate on UX margin/padding
else if (thisDecor.hasClass('slot_text')) {
innerDecor = thisDecor.find('textarea'); //to compensate on UX margin/padding
}
//FREESIZE problem: offset() is afected by rotation.
//solution: we disable rotation, take our measurements, and return the rotation
//DZ 19jul15: adding photo slot to this solution
var old_transform_decor;
var old_transform_inner_decor;
var old_transform_css_attribute = "transform";
var old_transform_inner_css_attribute = "transform";
if (thisDecor.hasClass('freesize') || thisDecor.hasClass('slot_photo')) {
//old_transform_decor = thisDecor.css('transform');
//DZ 9aug15: very strange error, sometimes happening in Safari/Mac. inner transform is in -webkit-transform so this fix doesnt apply.
//DZ 9aug15: used to be:
//old_transform_decor = thisDecor.css('transform');
//old_transform_inner_decor = innerDecor.css('transform');
//thisDecor.css('transform', 'none');
//innerDecor.css('transform', 'none');
//DZ 9aug15: now sniffing both transform and webkit transform
old_transform_decor = thisDecor.css(old_transform_css_attribute);
if (typeof old_transform_decor === "undefined") {
//try to read again from -webkit attribute
old_transform_css_attribute = "-webkit-transform";
old_transform_decor = thisDecor.css(old_transform_css_attribute);
}
old_transform_inner_decor = innerDecor.css(old_transform_inner_css_attribute);
//DZ 9aug15:
if (typeof old_transform_decor === "undefined") {
//try to read again from -webkit attribute
old_transform_inner_css_attribute = "-webkit-transform";
old_transform_inner_decor = innerDecor.css(old_transform_inner_css_attribute);
}
//thisDecor.css('transform', 'none');
//innerDecor.css('transform', 'none');
thisDecor.css(old_transform_css_attribute, 'none');
innerDecor.css(old_transform_inner_css_attribute, 'none');
//console.log('!!!!!!!!! 111 ', old_transform_css_attribute, old_transform_inner_css_attribute, old_transform_decor, old_transform_inner_decor);
}
var decorOffset = innerDecor.offset();
var frameOffset = innerDecor.parents('.editorFrame').offset();
decorOffset.top -= frameOffset.top;
decorOffset.left -= frameOffset.left;
var decorWidth = innerDecor.width();
var decorHeight = innerDecor.height();
//DZ 26mar17: rescaling for mobile
decorOffset.top /= desLogic.editor_scale;
decorOffset.left /= desLogic.editor_scale;
//fixes custom_textarea issue:
var decorMarginTop = parseInt(innerDecor.css('padding-top').replace('px', ''));
var newX = (decorOffset.left / originalWidth) * targetWidth;
var newY = ((decorOffset.top + decorMarginTop) / originalHeight) * targetHeight;
var newWidth = (decorWidth / originalWidth) * targetWidth;
var newHeight = (decorHeight / originalHeight) * targetHeight;
//resetting the freesize transform hiding
//DZ 19jul15: adding photo slot to this solution
if (thisDecor.hasClass('freesize') || thisDecor.hasClass('slot_photo')) {
//DZ 9aug15: used to be:
//thisDecor.css('transform', old_transform_decor);
//innerDecor.css('transform', old_transform_inner_decor);
//DZ 9aug15:
thisDecor.css(old_transform_css_attribute, old_transform_decor);
innerDecor.css(old_transform_inner_css_attribute, old_transform_inner_decor);
}
if (thisDecor.hasClass('slot_text')) {
var jqTextArea = thisDecor.find('textarea');
var text = jqTextArea.val();
//DZ 28jul14: added making sure that val isnt placeholder (IE9 ph hotfix doesnt take care of that)
if ($.trim(text) != '' && $.trim(text) != $.trim(jqTextArea.attr('placeholder'))) {
debug.log('rendering slot_text "' + text + '"');
//rescale font size:
var decorFontSize = jqTextArea.css('font-size');
var rescaled_font_size = parseFloat(decorFontSize.replace('px', '')) * (targetWidth / originalWidth);
var rescaled_line_height = parseFloat(jqTextArea.css('line-height').replace(',', '')) * (targetWidth / originalWidth);
//DZ 10aug14: sometimes line-height is "normal" or some other text
if (isNaN(rescaled_line_height)) {
rescaled_line_height = rescaled_font_size;
}
//DZ 10feb16:
//var decorFontFamily = jqTextArea.css('font-family');
var decorFontFamily = getFontName(jqTextArea.css('font-family'));
//console.log("___" + decorFontFamily + "___INITIAL" + decorFontFamily.length );
//___Courgette-Regular___ - WORKING
//___Courgette-Regular___ - NOT WOKRING
//
//___Courgette-Regular___17 WORKING
//___Courgette-Regular___17 NOT WORKING
/* DZ 10feb16: using getFontName instead of this code */
/*
decorFontFamily = strreplace(decorFontFamily, '"', '');
decorFontFamily = strreplace(decorFontFamily, "'", '');
//DZ 26jan16: if font name is single word (e.g. "David", and not e.g. "Times New Roman"), then font name should to between quotes for canvas text writing.
//DZ 4feb16: trying to order everything. all font names with singlequotes were removed singlequotes ('aspiredemibold' to aspiredemibold), only fonts with spaces have singlequotes. (AND NOT DOUBLE QUOTES)
//if (decorFontFamily.indexOf(' ') < 0)
if (decorFontFamily.indexOf(' ') > 0)
//DZ 29jan16 - after applying this fix, IE11 stops showing Arimo and more no-space fonts. however tested and working with single quotes
//decorFontFamily = '"' + decorFontFamily + '"';
decorFontFamily = "'" + decorFontFamily + "'";
*/
//console.log("___" + decorFontFamily + "___FINAL" + decorFontFamily.length);
//ROTATION:
var rotationDegress = get_rotation_degress_of_element(thisDecor);
if (rotationDegress == 0) {
//debug.log("CHECKING ROTATING AGAIN");
rotationDegress = get_rotation_degress_of_element(jqTextArea);
}
if (rotationDegress != 0)
debug.log('rotated text: ' + rotationDegress + 'deg');
//DZ 10feb16: adding quotes if wasnt already included
decorFontFamily = "'" + strreplace(decorFontFamily, "'", '') + "'";
ctx.font = rescaled_font_size + 'px ' + decorFontFamily;
ctx.fillStyle = (renderMode === "marginTextDetection") ? "black" : rgb2hex(jqTextArea.css('color'));
ctx.textAlign = jqTextArea.css('text-align');
ctx.textBaseline = 'top';
//X according to alignment. http://www.w3schools.com/tags/canvas_textalign.asp
var textX = 0;
if (ctx.textAlign == 'center')
textX = 0 + (newWidth / 2); //for center
else if (ctx.textAlign == 'right')
textX = 0 + newWidth;
//DZ 28jan15: adding this fix for fonts. location was off slightly sometimes.
//DZ 11jan16: moving this to after the rotation
//var ydifffixer = getRendererFontLocationFixDiff(rescaled_font_size, decorFontFamily);
//newY = newY + ydifffixer;
// save the current co-ordinate system before we screw with it
ctx.save();
//DZ 19jul15:
//ctx.translate(newX + textX + (newWidth / 2), newY + (newHeight / 2));
var translateX = newX + (newWidth / 2);
var translateY = newY + (newHeight / 2);
ctx.translate(translateX, translateY);
//console.log("FONT:: " + ctx.font); //rescaled_font_size + 'px ' + decorFontFamily);
//console.log("FONT TRANSLATE", translateX, translateY);
if (rotationDegress != 0)
ctx.rotate(rotationDegress * Math.PI / 180);
//DZ 11jan16: moving this to after the rotation
var ydifffixer = getRendererFontLocationFixDiff(rescaled_font_size, decorFontFamily);
ctx.translate(0, ydifffixer);
//split to lines (canvas doesnt do this automatically)
var curr_y = 0;
var lines = split_text_contents_to_line_seperated_spans(thisDecor.find('textarea'));
$(lines).each(function () {
var line = this;
//DZ 19jul15:
//ctx.fillText(line, 0 - (newWidth / 2), curr_y - (newHeight / 2), newWidth);
//DZ 19jan16: different HTML/CSS behavior per browser for ending spaces in each line, for middle or right aligned texts
//Chrome/Safari: (SEE BELOW COMMENT FROM 13aug17) entering post text spaces doesnt affect display (so we need to remove these spaces on redner, so they wont affect rendering)
//Firefox/IE: entering post text spaces affects display
//DZ 1may16: this fix isnt valid always, differenct chrome/safari behavior for multi-line texts with ending spaces. possible solution - edit out ending spaces when leaving HTML input
var isChrome = sayswho().toLowerCase().indexOf("chrome") >= 0;
var isSafari = (sayswho().toLowerCase().indexOf("safari") >= 0);
//DZ 13aug17: CIE-240 - chrome update sometime changed behavior - now entering post text spaces AFFECTS display in editor, so we keep those spaces in the render too
//if (isChrome || isSafari)
if (isSafari)
while (line.length > 0 && line[line.length - 1] == ' ')
line = line.substring(0, line.length - 1);
ctx.fillText(line, textX - (newWidth / 2), curr_y - (newHeight / 2), newWidth);
curr_y += rescaled_line_height;
});
//if (rotationDegress != 0) {
// ctx.rotate(-rotationDegress * Math.PI / 180);
//}
//rotating back:
ctx.restore();
}
succFunc();
}
else if (thisDecor.hasClass('slot_photo')) {
debug.log('rendering slot_photo');
var img_src = thisDecor.find('img').attr('src');
if (img_src == null || img_src.length == 0)
succFunc();
else {
get_panzoomed_photo_final_image(thisDecor, newWidth, newHeight, function (image_src) {
//image_src is base64 image after panning, zooming, border
async_create_and_load_image(image_src, function (base_image) {
//DZ 3aug14: rotation support
//ROTATION:
//rotation degrees(30) is returned as matrix - figuring out degress here: (if any)
var rotationDegress = get_rotation_degress_of_element(thisDecor);
canvasDrawRotatedImage(ctx, base_image, newX, newY, newWidth, newHeight, rotationDegress);
//ctx.drawImage(base_image, newX, newY, newWidth, newHeight);
succFunc();
});
});
}
}
//else if (thisDecor.hasClass('decor_full_image') || thisDecor.hasClass('decor_logo')) {
else if (thisDecor.hasClass('decor_full_image') || thisDecor.hasClass('decor_logo') || thisDecor.hasClass('decor_watermark')) {
debug.log('rendering logo/full_image');
var img_src = thisDecor.find('img').attr('src');
if (!img_src) //sometimes no img in container (in admin mode, after vemoing img with button)
succFunc();
//DZ 11oct15: removing watermark when rendering for ordered print
else if (now_rendering_without_watermark && thisDecor.hasClass('decor_watermark'))
succFunc();
else
async_create_and_load_image(img_src, function (base_image) {
//debug.log("RET=", base_image.src, newX, newY, newWidth, newHeight);
//DZ 1sep14: removed downscaleImage solution
if (false && is_admin_mode) {
//in admin we do better quality downscaling of full_image, mostly for thumb/preview generation.
//(OLD TODO: add in other cases? is it required? (is really downscaling? what about stickers? ecards preview?)
//TODO (NEW): remove downScaleImage method?
var scale = newWidth / base_image.width;
var resized_image = downScaleImage(base_image, scale);
ctx.drawImage(resized_image, newX, newY, newWidth, newHeight);
succFunc();
}
else {
ctx.drawImage(base_image, newX, newY, newWidth, newHeight);
succFunc();
}
});
}
else if (thisDecor.hasClass('sticker_container')) {
var svgUrl = thisDecor.find('img').attr('src');
debug.log('rendering sticker (' + svgUrl + ',xy=' + newX + ',' + newY + ' wh=' + newWidth + ',' + newHeight + ')');
var isSafari = (sayswho().toLowerCase().indexOf("safari") >= 0);
//safari has security issues when adding SVGs to canvas (canvas becomes tainted)
//so here we convert the svg to 500x500 png
//DZ 27aug14: also IE9
var isIE11 = sayswho() == "IE 11";
//DZ 26jan15: also IE10
var isIE10 = sayswho() == "MSIE 10";
//DZ 25aug15: didnt work with some stickers (Party fireworks stickers). removed safari Mac special treatment below and tested working on Safari Mac 8.0.7.
// removed special treatment. hopefully this does not cause regressions with older Safari Mac.
//if (isSafari || isIE9 || isIE11 || isIE10) {
//DZ 3sep15: filtering only safari versions < 8 (CIE-48 - Square Ecard: Party stickers don't displaying after clicking Preview & Send button (Safari Mac))
var isSafariMacRequiresFix = false;
if (isSafari) {
var safariVersion = sayswho_majorVersion();
isSafariMacRequiresFix = isSafari && parseInt(safariVersion) < 8;
debug.log("Safari detected, applying fix : " + (isSafariMacRequiresFix ? "yes" : "no"));
}
//YZ 19-AUG-18: endsWith pollyfill
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (search, this_len) {
if (this_len === undefined || this_len > this.length) {
this_len = this.length;
}
return this.substring(this_len - search.length, this_len) === search;
};
}
//YZ 19-AUG-18: This should only be used for SVG stickers, not for custom stickers (cause error in IE11)
var isSVG = svgUrl.endsWith(".svg");
if (isSVG && (isSafariMacRequiresFix || isSafariPC || isIE9 || isIE10 || isIE11)) {
debug.log('Safari Sticker fix: converting SVG to PNG using canvg');
var helperCanvas = document.createElement('canvas');
helperCanvas.width = 500;
helperCanvas.height = 500;
var helperCtx = helperCanvas.getContext("2d");
canvg(helperCanvas, svgUrl, {
log: true,
scaleWidth: 500,
scaleHeight: 500,
offsetX: 0,
offsetY: 0,
useCORS: true,
ignoreDimensions: true
});
var converted_svg_img_base64_src = helperCanvas.toDataURL('image/png', toDataUrlQuality);
async_create_and_load_image(converted_svg_img_base64_src, function (base_image) {
ctx.drawImage(base_image, newX, newY, newWidth, newHeight);
succFunc();
});
}
else {
async_create_and_load_image(svgUrl, function (base_image) {
if (base_image) {
try {
ctx.drawImage(base_image, newX, newY, newWidth, newHeight);
}
catch (ex) {
consloe.error('async_create_and_load_image drawImage exception: ', ex.toString());
}
}
else {
console.error('async_create_and_load_image: We got a bad image. Skipping');
}
succFunc();
});
}
}
else {
debug.error('unhandled card decor', thisDecor);
succFunc();
}
}
//returns final image (base64) of a slot_photo, after panzooming, filters, and border (frame)
function get_panzoomed_photo_final_image(jqSlotPhoto, newWidth, newHeight, succFunc) {
if (succFunc == null) {
debug.error("NULL SUCC-FUNC");
}
var ratio = newWidth / jqSlotPhoto.width();
var jqImg = jqSlotPhoto.find('.photo_holder img');
//DZ: getting cloneImg's width doesnt require .load event handler and changing func to async therefore
var clonedImg = $("
").attr("src", jqImg.attr("src")); // Make in memory copy of image to avoid css issues
var canvas = document.createElement('canvas');
canvas.width = newWidth;
canvas.height = newHeight;
var ctx = canvas.getContext("2d");
//PANZOOMED IMAGE - putting panzoomed image result to image:
ctx.save();
var transformationMatrix = jqImg.panzoom('getMatrix');
//changing to mid img (jq img) so transform origin will be 50% 50%
ctx.translate((jqImg.width() * ratio / 2), (jqImg.height() * ratio / 2));
ctx.transform(transformationMatrix[0], transformationMatrix[1], transformationMatrix[2], transformationMatrix[3], transformationMatrix[4] * ratio, transformationMatrix[5] * ratio);
//var base_image = new Image();
async_create_and_load_image(jqImg.attr("src"), function (base_image) {
ctx.drawImage(base_image, (-jqImg.width() * ratio / 2), (-jqImg.height() * ratio / 2), jqImg.width() * ratio, jqImg.height() * ratio);
ctx.restore();
//border: adding selected frame (actually "border") to canvas:
var current_frame_name = jqSlotPhoto.attr('current_frame');
var slot_has_frame = (current_frame_name != 'none' && current_frame_name != null && current_frame_name != '')
if (!slot_has_frame)
succFunc(canvas.toDataURL("image/jpeg", toDataUrlQuality));
else {
//two types of "frames": full shape mask on all image, or 4 corners+border:
var jqShapeLayer = jqSlotPhoto.find('.slot_frame_shape_layer');
if (jqShapeLayer.length > 0) {
//-- single image mask (e.g. heart, circle)
debug.log('border is single image mask (e.g. heart, circle)');
//var borderShapeWidth = jqShapeLayer.width() ;
//var borderShapeHeight = jqShapeLayer.height() * ratio;
//28jul14: OLD WAY
//ctx.translate(0, 0);
//async_create_and_load_image(jqShapeLayer.css("background-image").replace('url(', '').replace(')', ''), function (frame_image) {
// ctx.drawImage(frame_image, 0, 0, newWidth, newHeight);
// //END CONDITION:
// succFunc(canvas.toDataURL("image/jpeg"));
//});
ctx.translate(0, 0);
//DZ 27aug14: removed " and '. caused issues on IE9
var border_url = strreplace(strreplace(jqShapeLayer.css("background-image").replace('url(', '').replace(')', ''), '"', ''), "'", "");
debug.log('loading border "' + border_url + '"')
async_create_and_load_image(border_url, function (frame_image) {
debug.log('border image loaded');
var stamp_canvas_width;
var stamp_canvas_height;
//DZ 9feb16: totally different decision here
//var isWidePic = jqShapeLayer.css("background-image").indexOf('_wide.png') > 0;
//if (isWidePic) {
if ((newWidth * 1.0) / newHeight > frame_image.width / frame_image.height) {
//stamp_canvas_height = newHeight;
//stamp_canvas_width = stamp_canvas_height * frame_image.width / frame_image.height;
stamp_canvas_width = newWidth;
stamp_canvas_height = stamp_canvas_width * frame_image.height / frame_image.width;
}
else {
//DZ 25jan16 fix: found issues with blank space in TALL rendering of frames. flipping only tall frame rendering seems to work on all cases. tested x5 - no change appears to be needed for wide pic solution.
//stamp_canvas_width = newWidth;
//stamp_canvas_height = stamp_canvas_width * frame_image.height / frame_image.width;
stamp_canvas_height = newHeight;
stamp_canvas_width = stamp_canvas_height * frame_image.width / frame_image.height;
}
//height might be bigger than canvas height, so we calc offset:
var y_offset = 0;
if (stamp_canvas_height > newHeight) {
y_offset = -(stamp_canvas_height - newHeight) / 2;
}
var x_offset = 0;
if (stamp_canvas_width > newWidth) {
x_offset = -(stamp_canvas_width - newWidth) / 2;
}
ctx.drawImage(frame_image, x_offset, y_offset, stamp_canvas_width, stamp_canvas_height);
//END CONDITION:
succFunc(canvas.toDataURL("image/jpeg"), toDataUrlQuality);
});
}
else {
//-- 4 corner images + border
debug.log('border is 4 corner images + border');
var ratioX = newWidth / jqSlotPhoto.width();
var ratioY = newHeight / jqSlotPhoto.height();
//draw rectangle border
//DZ 17sep14: +1 hotfix
var borderWidth = 5 * ratioY * 2 + 1;
ctx.save();
ctx.lineWidth = borderWidth;
ctx.strokeStyle = "white";
//DZ 17sep14: -1 hotfix
ctx.strokeRect(0, 0, newWidth - 1, newHeight - 1);
ctx.restore();
var corners_done = 0;
var corners_loaded = 0;
var corner_sub_succ_func = function () {
debug.log('border #' + (corners_done + 1) + " done");
corners_done++;
if (corners_done == 4)
//END CONDITION:
succFunc(canvas.toDataURL("image/jpeg"), toDataUrlQuality);
};
//draw 4 corners:
jqSlotPhoto.find('.slot_frame_corner').each(function () {
var jqFrameCorner = $(this);
var cornerW = jqFrameCorner.width() * ratioX;
var cornerH = jqFrameCorner.height() * ratioY;
var cornerX;
var cornerY;
if (jQuery.isNumeric(jqFrameCorner.css('left').replace('px', '')))
cornerX = parseFloat(jqFrameCorner.css('left').replace('px', '')) * ratioX;
else
cornerX = newWidth - cornerW - (borderWidth / 2);
if (jQuery.isNumeric(jqFrameCorner.css('top').replace('px', '')))
cornerY = parseFloat(jqFrameCorner.css('top').replace('px', '')) * ratioY;
else
cornerY = newHeight - cornerH - (borderWidth / 2);
var corner_image_url = jqFrameCorner.css("background-image").replace('url(', '').replace(')', '');
//DZ 27aug14: removed " and '. caused issues on IE9
corner_image_url = strreplace(strreplace(corner_image_url, '"', ''), "'", "");
async_create_and_load_image(corner_image_url, function (corner_image) {
debug.log('border #' + (corners_done + 1) + " loaded");
corners_loaded++;
//debug.log('DADA', corner_image, cornerX, cornerY, cornerW, cornerH);
ctx.drawImage(corner_image, cornerX, cornerY, cornerW, cornerH);
//END CONDITION (kinda)
corner_sub_succ_func();
});
});
}
}
});
}
//YZ 02Dec15: Adding optional quality parameter
//succ func accepts base64 final image of a card page
function render_image_from_frame(jqEditorFrame, canvasW, canvasH, succFunc, quality) {
render_canvas_from_frame(jqEditorFrame, canvasW, canvasH, null, function (canvas) {
//DZ 29jan15: removed finalJpegQuality param
//var jpegQuality = toDataUrlQuality;
//if (finalJpegQuality)
// jpegQuality = finalJpegQuality;
var imgData = canvas.toDataURL("image/jpeg", quality || toDataUrlQuality);
//[CIE-12] - The bottom part of downloaded as pdf or img portrait Invitations is truncated in IE11
//DZ 20sep15: some IEs have canvas 2048 issue. so we detect these cases, and try to hotfix it
//succFunc(imgData);
var isAnyIE = shouldApplyOutputCanvasSizeCheck();
var shouldCheckSizes = isAnyIE && (canvasW > 2000 || canvasH > 2000);
if (!shouldCheckSizes)
succFunc(imgData);
else //IE
{
async_create_and_load_image(imgData, function (imgObj) {
//YZ 25oct15: adding parseInt since canvasW,canvasH are strings
var allAsPlanned = parseInt(canvasW) === imgObj.width && parseInt(canvasH) === imgObj.height;
if (allAsPlanned)
succFunc(imgData);
else {
//issue detected:
console.warn("DETECTED IE CANVAS ISSUE.", canvasW, canvasH, imgObj.width, imgObj.height);
//new proportions (max 2000):
var newCanvasW;
var newCanvasH;
if (canvasW >= canvasH) {
newCanvasW = 2000;
var ratio = newCanvasW / canvasW;
newCanvasH = ratio * canvasH;
}
else {
newCanvasH = 2000;
var ratio = newCanvasH / canvasH;
newCanvasW = ratio * canvasW;
}
//recurse call with new proportions:
render_image_from_frame(jqEditorFrame, newCanvasW, newCanvasH, succFunc)
}
});
}
});
}
//used in admin:
function render_image_from_frame_as_png(jqEditorFrame, canvasW, canvasH, succFunc) {
render_canvas_from_frame(jqEditorFrame, canvasW, canvasH, null, function (canvas) {
var imgData = canvas.toDataURL("image/png", toDataUrlQuality);
succFunc(imgData);
});
}
//DZ 11nov15:
//succFunc will return null for OK, and a jqTextSlot array if detectecd on borders (marginTextDetection)
function runMarginTextDetection(succFunc) {
var jqEditorFrame = $('.editorTab .editorFrame:first');
render_canvas_from_frame(jqEditorFrame, jqEditorFrame.width(), jqEditorFrame.height(), "marginTextDetection", function (jqTextSlots) {
if (jqTextSlots == null || jqTextSlots.length == 0)
debug.log('margin text detection OK');
else
debug.log('margin text detection failed', jqTextSlots);
succFunc(jqTextSlots);
});
}
//checks a canvas, for any non-white pixels at borders. this is done for each textslot tested
function checkCanvasForMargins(ctx, targetWidth, targetHeight, borderWidth) {
var amountOfPeeks = 0;
var testDataStripe = function (data, startX, endX, startY, endY) {
debug.log("testing stripe", startX, endX, startY, endY);
var ok = true;
for (var x = startX ; ok && x < endX ; x++)
for (var y = startY ; ok && y < endY ; y++) {
var index = 4 * (x + y * targetWidth);
amountOfPeeks++;
if (data[index] != 255 || data[index + 1] != 255 || data[index + 2] != 255) {
debug.log("failed margin check on ", x, y);
ok = false;
}
}
return ok;
}
var data = ctx.getImageData(0, 0, targetWidth, targetHeight).data;
var ok = testDataStripe(data, 0, targetWidth, 0, borderWidth) && //TOP MARGIN
testDataStripe(data, 0, targetWidth, targetHeight - borderWidth, targetHeight) && //BOTTOM
testDataStripe(data, 0, borderWidth, borderWidth, targetHeight - borderWidth) && //LEFT
testDataStripe(data, targetWidth - borderWidth, targetWidth, borderWidth, targetHeight - borderWidth); //RIGHT
debug.log('amountOfPeeks++;', amountOfPeeks);
return ok;
}
//---------------------------------------------------------------------------------------
// DOWNLOAD METHODS
//---------------------------------------------------------------------------------------
var pdfDoc;
//DZ 11mar18: SAM code merge
//function download_card_as_pdf() {
function download_card_as_pdf(samCallback) {
debug.log('=== CARD PDF EXPORT - started ===');
//DZ 14aug17: ME-131 - repositioning the 'designer.download'
//$.publish('designer.download', [editorMode, 'pdf', current_print_page_size_mode, current_page_type]); //cards
now_loading_start();
var isLandscapeLayout = getLayout() == "landscape";
//Page Settings:
//A4 is 210xx297
//LTR is 216x279
//A4 settings:
var page_width = 210;
var page_height = 297;
if (current_page_type == "letter") {
page_width = 216;
page_height = 279;
}
var pdf_image_width;
var apply_landscape_pdf_fixes = false; //LANDSPACE PDF PAGE - NOT LADNSCAPE LAYOUT!
if (!isLandscapeLayout) {
if (current_print_page_size_mode == 'full') {
//FULL PAGE PRINT
pdfDoc = new jsPDF('landscape', 'mm', current_page_type);
apply_landscape_pdf_fixes = true; //2nd page should be "rotated"
//landscape A4 - swapping width & height:
var t = page_width;
page_width = page_height;
page_height = t;
if ($('body').hasClass('layout_square'))
pdf_image_width = 127; //~5inch - comes out smaller with "fit to page"
else
pdf_image_width = 121; //according to card ratio 1.46385542168674, this will result in 7inch high card (178mm)
}
else {
//HALF PAGE PRINT
pdfDoc = new jsPDF('portrait', 'mm', current_page_type);
pdf_image_width = 95; //according to card ratio 1.46385542168674, this will result in 7inch high card (178mm)
}
}
else {
//LANDSCAPE LAYOUT mode:
if (current_print_page_size_mode == 'full') {
//FULL PAGE PRINT
pdfDoc = new jsPDF('portrait', 'mm', current_page_type);
pdf_image_width = 180;
}
else {
//HALF PAGE PRINT
pdfDoc = new jsPDF('landscape', 'mm', current_page_type);
apply_landscape_pdf_fixes = true; //2nd page should be "rotated"
//landscape A4 - swapping width & height:
var t = page_width;
page_width = page_height;
page_height = t;
pdf_image_width = 121;
}
}
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
var pdf_image_height = pdf_image_width * heightRatio;
//layout: page1: [IMGBACK] [IMGFRONT]
// page2: [INNER1] [INNER2]
//LOCATING EACH IMAGE:
//page1 x,y:
var backX, backY, frontX, frontY;
//page2 x,y:
var inner1X, inner1Y, inner2X, inner2Y;
if (!isLandscapeLayout) {
//page 1: side by side
backX = (page_width - (2 * pdf_image_width)) / 2;
frontX = backX + pdf_image_width;
frontY = (page_height - pdf_image_height) / 2;
if (current_print_page_size_mode == 'half')
frontY = 10;
backY = frontY;
//page 2: same as page 1
inner1X = backX;
inner2X = frontX;
inner1Y = frontY;
inner2Y = backY;
}
else {
//landscape: one on top of other
backX = (page_width - pdf_image_width) / 2;
if (current_print_page_size_mode == 'half')
backX = 20;
backY = (page_height - (2 * pdf_image_height)) / 2;
frontX = backX;
frontY = backY + pdf_image_height;
//page 2: same as page 1, but switched
inner2X = backX;
inner1X = frontX;
inner2Y = frontY;
inner1Y = backY;
}
var currentImg = null; // to save memory, each time working with single img
//canvas size used to render each of the 4 images to be inserted to the PDF
var canvasW = 1500;
var canvasH = parseInt(canvasW * heightRatio);
debug.log('canvas size used for rendering: ' + canvasW + 'x' + canvasH);
//FRONT
render_image_from_frame($('.tabBack .editorFrame'), canvasW, canvasH, function (currentImg) {
var rotationBackDegrees = 0;
if (isLandscapeLayout)
rotationBackDegrees = 180;
//DZ 18may15: all rotations cancelled due to yair's request
//cancelled: rotationBackDegrees = 0;
get_rotated_image_helper(currentImg, rotationBackDegrees, function (currentImg) {
//debug.log('rendered page 1');
pdfDoc.addImage(currentImg, 'JPEG', backX, backY, pdf_image_width, pdf_image_height);
//BACK:
render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (currentImg) {
//debug.log('rendered page 2');
pdfDoc.addImage(currentImg, 'JPEG', frontX, frontY, pdf_image_width, pdf_image_height);
//adding rect around front page:
pdfDoc.setDrawColor(170, 170, 170);
//DZ 2mar17: CIE-184 Make border line for cards + invites prints + PDF thinner
//pdfDoc.setLineWidth('0.25');
pdfDoc.setLineWidth('0.05');
pdfDoc.rect(frontX, frontY,
pdf_image_width, pdf_image_height);
//NEWPAGE:
pdfDoc.addPage();
var rotationDegrees = 0;
if (isLandscapeLayout) {
//LANDSCAPE CARD LAYOUT. similiar but different
if (current_print_page_size_mode == 'full') {
rotationDegrees = 180;
//switch inner 1,2 y's:
var t = inner1Y;
inner1Y = inner2Y;
inner2Y = t;
}
}
//other layouts
else if (apply_landscape_pdf_fixes) {
//LANDSCAPE PDF PAGE (done before landscape layouts, means that PDF page is landscape oriented)
//each card should be rotated 270degs:
rotationDegrees = 180;
//swap inner 1,2 x's:
var t = inner1X;
inner1X = inner2X;
inner2X = t;
}
//DZ 18may15: all rotations cancelled due to yair's request
//cacelled: rotationDegrees = 0;
//INSIDE 1:
render_image_from_frame($('.tabInside .editorFrame:first'), canvasW, canvasH, function (currentImg) {
//debug.log('rendered page 3');
get_rotated_image_helper(currentImg, rotationDegrees, function (currentImg) {
pdfDoc.addImage(currentImg, 'JPEG', inner1X, inner1Y, pdf_image_width, pdf_image_height);
//INSIDE2:
render_image_from_frame($('.tabInside .editorFrame:nth-child(2)'), canvasW, canvasH, function (currentImg) {
get_rotated_image_helper(currentImg, rotationDegrees, function (currentImg) {
//debug.log('done with mid pages');
pdfDoc.addImage(currentImg, 'JPEG', inner2X, inner2Y, pdf_image_width, pdf_image_height);
debug.log('=== PDF EXPORT - DONE ===');
now_loading_stop();
//DZ 14aug17: ME-131
var func_report_dl_event = function () {
//DZ 14aug17: ME-131 - putting the 'designer.download' event where required
console.log("reporting card PDF DL");
//DZ 20aug17: added default_page_size to event reporting
$.publish('designer.download', [editorMode, 'pdf', current_print_page_size_mode, current_page_type, window.default_page_size ]); //cards
};
//INITIATING DOWNLOAD:
//IMPORTANT: code shared with download_invitation_as_pdf
//DZ 24aug15: safari desktop doesnt work (suddenly?) with saveAs (might be realted to DZ 9aug15)
var isSafariDesktop = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
var can_direct_download = browser_category == "desktop" && !isSafariPC && !isSafariDesktop;
//DZ 19sep16: new: uploading to s3 for safari users
//DZ 8may17: also android>7 because of CIE-191 (Android7: Download not working for Android 7)
//var isSafari = sayswho().toLowerCase().indexOf("safari") >= 0;
var shouldUploadToServer = sayswho().toLowerCase().indexOf("safari") >= 0 || parseInt(getAndroidVersion()) >= 7;
//DZ 11mar18: SAM code merge
//if (shouldUploadToServer)
//DZ 1jan31 SAM - sam support, returns base64 of PDF document to ionic scope
if (editorAppMode==='SAM' && samCallback){
var base64pdf = pdfDoc.output('datauri');
samCallback(base64pdf);
}
else if (shouldUploadToServer)
{
//generate the base64 PDF
//var out =
now_loading_start();
var base64pdf = pdfDoc.output('blob'); //datauristring'); //'data:application/pdf;base64,' + out; // Base64.encode(out);
var randomNum = parseInt(Math.random() * 100000000);
var temp_filename = get_download_filename() + "_" + randomNum + ".pdf";
desLogic.upload_temp_file_to_s3(base64pdf, temp_filename, 'application/pdf', function (newUrl) {
now_loading_stop();
//success method:
if (inMobileMode) {
uxController.bind_simple_drawer("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
$('#simple-drawer-button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
//DZ 14aug17: ME-131
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
//$('#popup_simple_button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
$('#popup_simple_button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl);
//DZ 14aug17: ME-131
$('#popup_simple_button').click(func_report_dl_event);
uxController.show_popup_centered($('#popup_simple_template'));
}
}, function (err) {
//err method
console.error('failed to upload to s3', err);
});
}
else if (can_direct_download) {
debug.log('PDF direct download');
//DIRECT DOWNLOAD
pdfDoc.save(get_download_filename() + '.pdf');
pdfDoc = null;
//DZ 14aug17: ME-131
func_report_dl_event();
}
else {
//direct download isnt supported - showing download button
debug.log('PDF popup download');
//desLogic.bind_simple_popup("download_pdf", "Download PDF", "Your PDF is now ready.", "Download");
if (inMobileMode) {
uxController.bind_simple_drawer("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
//DZ 14aug17: ME-131
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
uxController.show_popup_centered($('#popup_simple_template'));
//DZ 14aug17: ME-131
$('#popup_simple_button').click(func_report_dl_event);
}
}
});
});
});
});
});
});
});
}
//========================== INVITATIONS PDF / JPEG DOWNLOADS ==========================
function download_invitation_as_pdf(num_per_page) {
download_invitation_as_pdf_with_custom_page_size(num_per_page, null);
}
function download_invitation_as_pdf_with_custom_page_size(num_per_page, pdf_page_width_mm) {
desLogic.mark_as_clean();
desLogic.close_popups_or_drawers();
now_loading_start();
debug.log('=== INVITATION PDF EXPORT - started ===');
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
//quality of rendered canvas:
//var canvasW = 1500;
//var canvasW = config_render.invitation_pdf_width;
//var canvasH = parseInt(canvasW * heightRatio);
var dimensions = desLogic.getOrderRenderDimensions(renderDimensions.production);
var canvasW = dimensions.width;
var canvasH = parseInt(canvasW * heightRatio);
if (!desLogic.isOFBConnected()) $(".decor_watermark").show();
render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (currentImg) {
if (!desLogic.isOFBConnected()) $(".decor_watermark").hide();
//according to 297x210mm per A4, leaving 20mm margins
//A4 is 210xx297
//LTR is 216x279
//A4 settings:
var page_width = 210;
var page_height = 297;
//always the page type:
if (true) { // || current_page_type == "letter") {
page_width = 216;
page_height = 279;
}
if (pdf_page_width_mm != null) {
page_width = pdf_page_width_mm;
page_height = page_width * heightRatio;
}
//rect color:
var inner_draw_invitation_func = function (currentImg, x, y, w, h) {
pdfDoc.setDrawColor(170, 170, 170);
//DZ 2mar17: CIE-184 Make border line for cards + invites prints + PDF thinner
//pdfDoc.setLineWidth('0.25');
pdfDoc.setLineWidth('0.05');
pdfDoc.addImage(currentImg, 'JPEG', x, y, w, h);
pdfDoc.rect(x, y, w, h);
};
var current_layout = getLayout();
if (num_per_page == 1) {
//DZ 16jun15: changed on ehud's request
//var pdfCanvasW = 180;
var pdfCanvasW = 193;
var pdfCanvasH;
var orientation = "portrait";
//DZ 29aug16: added no-border mode, with given 'mm' size for page width
if (pdf_page_width_mm != null) {
if (current_layout == 'landscape') {
orientation = 'landscape';
var t = page_width;
page_width = page_height;
page_height = t;
pdfCanvasW = page_height;
pdfCanvasH = page_width;
}
else {
pdfCanvasH = page_height;
pdfCanvasW = page_width;
}
}
else {
if (current_layout == 'square') {
pdfCanvasW = 215;
}
else if (current_layout == 'landscape') {
orientation = 'landscape';
//switch page w/h for landscape:
var t = page_width;
page_width = page_height;
page_height = t;
pdfCanvasW = 277;
}
pdfCanvasH = pdfCanvasW * heightRatio;
}
var marginTop = (page_height - pdfCanvasH) / 2;
var marginLeft = (page_width - pdfCanvasW) / 2;
//DZ 29aug16: added no-border mode, with given 'mm' size for page width
var pageSizeSetting = 'letter';
if (pdf_page_width_mm != null) {
pageSizeSetting = [pdfCanvasW, pdfCanvasH];
marginTop = 0;
marginLeft = 0;
}
pdfDoc = new jsPDF(orientation, 'mm', pageSizeSetting);
inner_draw_invitation_func(currentImg, marginLeft, marginTop, pdfCanvasW, pdfCanvasH);
debug.log('=== PDF EXPORT - DONE ===');
}
else if (num_per_page == 2) {
var pdfCanvasW = 123.13; //YZ 23-5-19 : changing from 121
//DZ 15jun15: ehud asked square images to be slightly larger
if (current_layout == 'square')
pdfCanvasW = 133;
var pdfCanvasH = pdfCanvasW * heightRatio; //*1.44 = ~170mm ~ 7in
var marginTop = (page_width - pdfCanvasH) / 2;
var marginLeft = (page_height - (2 * pdfCanvasW)) / 2;
if (current_layout != 'landscape') {
pdfDoc = new jsPDF('landscape', 'mm', 'letter');
inner_draw_invitation_func(currentImg, marginLeft, marginTop, pdfCanvasW, pdfCanvasH);
inner_draw_invitation_func(currentImg, marginLeft + pdfCanvasW, marginTop, pdfCanvasW, pdfCanvasH);
}
else {
//LADNSCAPE INVITATION (printed on portrait)
pdfCanvasW = 177.8; //YZ 23-5-19 : changing from 180
pdfCanvasH = pdfCanvasW * heightRatio;
marginTop = (page_height - (2 * pdfCanvasH)) / 2;
marginLeft = (page_width - pdfCanvasW) / 2;
pdfDoc = new jsPDF('portrait', 'mm', 'letter');
inner_draw_invitation_func(currentImg, marginLeft, marginTop, pdfCanvasW, pdfCanvasH);
inner_draw_invitation_func(currentImg, marginLeft, marginTop + pdfCanvasH, pdfCanvasW, pdfCanvasH);
}
}
else {
//num_per_page == 4
var pdfCanvasW = 90;
var orientation = "portrait";
if (current_layout == 'landscape') {
orientation = 'landscape';
pdfCanvasW = 130;
//switch page w/h hotfix
var t = page_width; page_width = page_height; page_height = t;
}
var pdfCanvasH = pdfCanvasW * heightRatio; //~137
var marginTop = (page_height - (2 * pdfCanvasH)) / 2;
var marginLeft = (page_width - (2 * pdfCanvasW)) / 2;
pdfDoc = new jsPDF(orientation, 'mm', 'letter');
inner_draw_invitation_func(currentImg, marginLeft, marginTop, pdfCanvasW, pdfCanvasH);
inner_draw_invitation_func(currentImg, marginLeft + pdfCanvasW, marginTop, pdfCanvasW, pdfCanvasH);
inner_draw_invitation_func(currentImg, marginLeft, marginTop + pdfCanvasH, pdfCanvasW, pdfCanvasH);
inner_draw_invitation_func(currentImg, marginLeft + pdfCanvasW, marginTop + pdfCanvasH, pdfCanvasW, pdfCanvasH);
}
now_loading_stop();
//cant donwload async created pdf here on some browsers
//INITIATING DOWNLOAD:
//IMPORTANT: code shared with download_card_as_pdf
//DZ 3sep14: removed all Safari from this. didnt work on Safari 7 Mac (opened in same window) - used to be only safariPC
//DZ 14aug17: ME-131
var func_report_dl_event = function () {
//DZ 14aug17: ME-131 - putting the 'designer.download' event where required
console.log("reporting invi PDF DL");
$.publish('designer.download', [editorMode, 'pdf', num_per_page]);
var premium_no_watermark_selected = $('#premium_no_watermark_onoff').is(':checked');
if (premium_no_watermark_selected)
$.publish('designer.download_premium', [editorMode, 'pdf', num_per_page]);
};
var can_direct_download = browser_category == "desktop" && sayswho().indexOf("Safari ") < 0;
//DZ 19sep16: new: uploading to s3 for safari users
//DZ 8may17: also android>7 because of CIE-191 (Android7: Download not working for Android 7)
//var isSafari = sayswho().toLowerCase().indexOf("safari") >= 0;
var shouldUploadToServer = sayswho().toLowerCase().indexOf("safari") >= 0 || parseInt(getAndroidVersion())>=7;
if (shouldUploadToServer) {
//generate the base64 PDF
now_loading_start();
var base64pdf = pdfDoc.output('blob'); //datauristring'); //'data:application/pdf;base64,' + out; // Base64.encode(out);
var randomNum = parseInt(Math.random() * 100000000);
var temp_filename = get_download_filename() + "_" + randomNum + ".pdf";
console.log('dl_inv_as_pdf - uploading first');
desLogic.upload_temp_file_to_s3(base64pdf, temp_filename, 'application/pdf', function (newUrl) {
now_loading_stop();
//success method:
if (inMobileMode) {
uxController.bind_simple_drawer("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
$('#simple-drawer-button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
//$('#simple-drawer-button').on("click", function () {
// $.publish('designer.download', [editorMode, 'pdf', num_per_page]);
//});
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
$('#popup_simple_button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
//$('#popup_simple_button').on("click", function () {
// $.publish('designer.download', [editorMode, 'pdf', num_per_page]);
//});
$('#popup_simple_button').click(func_report_dl_event);
uxController.show_popup_centered($('#popup_simple_template'));
}
}, function (err) {
//err method
console.error('failed to upload to s3', err);
});
}
else if (can_direct_download) {
//DIRECT DOWNLOAD
//YZ 10-3-16: Adding delay of 1 Sec, due to FF bug, that fails downloading PDF
console.log('dl_inv_as_pdf - direct DL');
//DZ 8may17: adding timeout only for firefox
var isFirefox = (sayswho().toLowerCase().indexOf("firefox") >= 0);
if (isFirefox)
setTimeout(function () {
pdfDoc.save(get_download_filename() + '.pdf');
pdfDoc = null;
func_report_dl_event();
}, 1000);
else
{
pdfDoc.save(get_download_filename() + '.pdf');
pdfDoc = null;
func_report_dl_event();
}
//$.publish('designer.download', [editorMode, 'pdf', num_per_page])
}
else {
console.log('dl_inv_as_pdf - indirect DL');
if (inMobileMode) {
uxController.bind_simple_drawer("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
//DZ 14aug17: had no reporting here
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
//DZ 14aug17: had no reporting here
$('#popup_simple_button').click(func_report_dl_event);
uxController.show_popup_centered($('#popup_simple_template'));
}
}
//DZ 2sep15: new analysis for outputted widths:
try {
//var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
//var isIE9 = sayswho() == "MSIE 9";
////DZ 20sep15: also IE10
//var isIE10 = sayswho() == "MSIE 10";
var isAnyIE = shouldApplyOutputCanvasSizeCheck();
async_create_and_load_image(currentImg, function (imgObj) {
var allAsPlanned = canvasW === imgObj.width && canvasH === imgObj.height;
debug.log('designer.render.canvasSize', [canvasW, canvasH, imgObj.width, imgObj.height, allAsPlanned ? "OK" : "BAD", isAnyIE ? "IE" : "notIE"]);
$.publish('designer.render.canvasSize', [canvasW, canvasH, imgObj.width, imgObj.height, allAsPlanned ? "OK" : "BAD", isAnyIE ? "IE" : "notIE"]);
});
}
catch (e) {
console.error('in canvasAnalysis', e);
}
});
}
function download_invitation_as_jpeg() {
//DZ 14aug17: ME-131
//$.publish('designer.download', [editorMode, 'jpeg']); //invi
desLogic.close_popups_or_drawers();
now_loading_start();
debug.log('=== IMAGE EXPORT - started ===');
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
//DZ 11mar18: SAM code merge - this fix didnt exist in SAM.
//YZ 21/1/17 - Setting diffenet jpeg width according to layout
//var canvasW = config_render.invitation_jpeg_width;
var layout = getLayout();
var canvasW = config_render.invitation_jpeg_width[layout];
var canvasH = parseInt(canvasW * heightRatio);
if (!desLogic.isOFBConnected()) $(".decor_watermark").show();
//$(".decor_watermark").show();
desLogic.close_popups_or_drawers();
render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (img_src) {
if (!desLogic.isOFBConnected()) $(".decor_watermark").hide();
//$(".decor_watermark").hide();
debug.log('=== IMAGE EXPORT - done ===');
//DZ 14aug17: ME-131
var func_report_dl_event = function () {
console.log("reporting invi JPEG DL");
$.publish('designer.download', [editorMode, 'jpeg']); //invi
var premium_no_watermark_selected = $('#premium_no_watermark_onoff').is(':checked');
if (premium_no_watermark_selected)
$.publish('designer.download_premium', [editorMode, 'jpeg']);
};
download_image_helper(img_src, func_report_dl_event);
//DZ 2sep15: new analysis for outputted widths:
try {
//var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
//var isIE9 = sayswho() == "MSIE 9";
//var isIE10 = sayswho() == "MSIE 10";
//var isAnyIE = isIE || isIE9 || isIE10;
var isAnyIE = shouldApplyOutputCanvasSizeCheck();
async_create_and_load_image(img_src, function (imgObj) {
var allAsPlanned = canvasW === imgObj.width && canvasH === imgObj.height;
debug.log('designer.render.canvasSize', [canvasW, canvasH, imgObj.width, imgObj.height, allAsPlanned ? "OK" : "BAD", isAnyIE ? "IE" : "notIE"]);
$.publish('designer.render.canvasSize', [canvasW, canvasH, imgObj.width, imgObj.height, allAsPlanned ? "OK" : "BAD", isAnyIE ? "IE" : "notIE"]);
});
}
catch (e) {
console.error('in canvasAnalysis', e);
}
now_loading_stop();
});
}
//========================== ECARDS PDF / JPEG DOWNLOADS ==========================
function download_ecard_as_pdf() {
now_loading_start();
//DZ 14aug17: ME-131
//$.publish('designer.download', [editorMode, 'pdf']); //ecard
var func_report_dl_event = function () {
//DZ 14aug17: ME-131 - putting the 'designer.download' event where required
console.log("reporting ecard PDF DL");
$.publish('designer.download', [editorMode, 'pdf']); //ecard
};
var current_layout = getLayout();
debug.log('=== ECARD PDF EXPORT - started ===');
if (current_layout != 'landscape')
pdfDoc = new jsPDF('landscape');
else
pdfDoc = new jsPDF();
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
var marginTop = 7;
var marginLeft = 13;
var pdfCanvasW;
if (current_layout != 'landscape')
pdfCanvasW = 132;
else
pdfCanvasW = 180;
var pdfCanvasH = pdfCanvasW * heightRatio; //197
//var result_img_src = create_ecard_image_from_page();
//DZ 26jan17: reworked method create_ecard_image_from_page to be async:
//var result_img_src = create_ecard_image_from_page(config_render.ecard_resize_to_pdf);
create_ecard_image_from_page(config_render.ecard_resize_to_pdf, function (result_img_src) {
if (current_layout != 'landscape')
pdfDoc.addImage(result_img_src, 'JPEG', marginLeft, marginTop, pdfCanvasW * 2, pdfCanvasH);
else
pdfDoc.addImage(result_img_src, 'JPEG', marginLeft, marginTop, pdfCanvasW, pdfCanvasH * 2);
debug.log('=== PDF EXPORT - DONE ===');
//cant donwload async created pdf here on some browsers
//var isSafariPC = false;
//var ua = navigator.userAgent.toLowerCase();
//if (sayswho().toLowerCase().indexOf("safari") !== -1 && ua.indexOf("windows") !== -1) {
// // Looks like Safari on Windows
// isSafariPC = true;
//}
now_loading_stop();
var can_direct_download = browser_category == "desktop" && !isSafariPC;
//DZ 15may17: adding safari/android7 hotfix:
var shouldUploadToServer = sayswho().toLowerCase().indexOf("safari") >= 0 || parseInt(getAndroidVersion()) >= 7;
if (shouldUploadToServer)
{
//generate the base64 PDF
//var out =
now_loading_start();
var base64pdf = pdfDoc.output('blob'); //datauristring'); //'data:application/pdf;base64,' + out; // Base64.encode(out);
var randomNum = parseInt(Math.random() * 100000000);
var temp_filename = get_download_filename() + "_" + randomNum + ".pdf";
desLogic.upload_temp_file_to_s3(base64pdf, temp_filename, 'application/pdf', function (newUrl) {
now_loading_stop();
//success method:
if (inMobileMode) {
uxController.bind_simple_drawer("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
$('#simple-drawer-button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
//DZ 14aug17: ME-131
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("Download"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
//$('#popup_simple_button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl).attr('target', '_blank');
$('#popup_simple_button').attr('download', get_download_filename() + ".pdf").attr('href', newUrl);
uxController.show_popup_centered($('#popup_simple_template'));
//DZ 14aug17: ME-131
$('#popup_simple_button').click(func_report_dl_event);
}
}, function (err) {
//err method
console.error('failed to upload to s3', err);
});
}
else if (can_direct_download) {
//DIRECT DOWNLOAD
pdfDoc.save(get_download_filename() + '.pdf');
pdfDoc = null;
desLogic.close_popups_or_drawers();
func_report_dl_event();
}
else {
//direct download isnt supported - showing download button
if (inMobileMode) {
uxController.bind_simple_drawer("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
$('#simple-drawer-button').click(func_report_dl_event);
}
else {
uxController.bind_simple_popup("download_pdf", getLocCaption("download_pdf"), getLocCaption("download_pdf_desc"), getLocCaption("Download"));
uxController.show_popup_centered($('#popup_simple_template'));
$('#popup_simple_button').click(func_report_dl_event);
}
}
});
}
function download_ecard_as_jpeg() {
desLogic.close_popups_or_drawers();
//DZ 14aug17: ME-131
//$.publish('designer.download', [editorMode, 'jpeg']); //ecard
var func_report_dl_event = function () {
//DZ 14aug17: ME-131 - putting the 'designer.download' event where required
console.log("reporting ecard JPEG DL");
$.publish('designer.download', [editorMode, 'jpeg']); //ecard
};
now_loading_start();
debug.log('=== ECARD IMAGE EXPORT - started ===');
//var result_img_src = create_ecard_image_from_page();
//DZ 26jan17: reworked method create_ecard_image_from_page to be async:
//var result_img_src = create_ecard_image_from_page(config_render.ecard_resize_to_jpeg);
create_ecard_image_from_page(config_render.ecard_resize_to_jpeg, function (result_img_src) {
download_image_helper(result_img_src, func_report_dl_event);
now_loading_stop();
debug.log('=== ECARD IMAGE EXPORT - done ===');
});
}
function create_ecard_image_from_page(targetImgWidth, succFunc) {
//DZ REDESIGN 26jan17: reworked this method:
//USED TO: synced method, renders a eCard image from EXSITING renedered image on preview page
//NOW: async method, renders a new eCard image from DOM
//target image width contains BOTH editor frames (so its 2x than the usual canvasW)
var current_layout = getLayout();
//we already have the two images on the page preview:
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
//default:
//DZ 31aug14: ecard img not showing on iPad. changed from 1480
var canvasW;
if (current_layout != 'landscape')
canvasW = (targetImgWidth) ? (targetImgWidth / 2) : (1200);
else
canvasW = (targetImgWidth) ? targetImgWidth : (1200);
//dz 15dec14: adding new layouts
var canvasH = parseInt(canvasW * heightRatio);
debug.log('-- ecard_image_from_page ' + canvasW + 'x' + canvasH + 'px --');
var newCanvas = document.createElement('canvas');
if (current_layout != 'landscape') {
newCanvas.width = canvasW * 2;
newCanvas.height = canvasH;
}
else {
newCanvas.width = canvasW;
newCanvas.height = canvasH * 2;
}
//console.log("create_ecard_image_from_page", "canvas=" + canvasW + 'x' + canvasH, 'newCanvas=' + newCanvas.width + 'x' + newCanvas.height);
//DZ 26jan17:
//var imgFront = $('#ecard_preview_container img:first')[0];
//var imgBack = $('#ecard_preview_container img:last')[0];
//RENDERING BOTH SIDES:
render_image_from_frame($('.editorTab .editorFrame:first'), canvasW, canvasH, function (imgSrcFront) {
render_image_from_frame($('.editorTab .editorFrame:last'), canvasW, canvasH, function (imgSrcBack) {
//LOADING BOTH SIDES TO IMAGES:
async_create_and_load_image(imgSrcFront, function (imgFront) {
async_create_and_load_image(imgSrcBack, function (imgBack) {
var ctx = newCanvas.getContext("2d");
ctx.drawImage(imgFront, 0, 0, canvasW, canvasH);
if (current_layout != 'landscape')
ctx.drawImage(imgBack, canvasW, 0, canvasW, canvasH);
else
ctx.drawImage(imgBack, 0, canvasH, canvasW, canvasH);
var ret = newCanvas.toDataURL("image/jpeg", toDataUrlQuality);
succFunc(ret);
});
});
});
});
//return ret;
}
//---------------------------------------------------------------------------------------
// PRINT METHODS
//---------------------------------------------------------------------------------------
//current selected print mode:
var current_print_page_size_mode; //changed from UX
var current_page_type; //changed from UX - letter or A4
//DZ 13sep14:
//gets paper (.page element) WxH according to page_type (a4/letter) and browser
//USED ONLY IN CARDS
function get_print_page_dims() {
var page_width = 210;
var page_height = 293; //DZ: fixing from 297 to 293 gave better centering results on a4
if (current_page_type == "letter") {
page_width = 216;
page_height = 279;
}
var diff_height = 0;
var diff_width = 0;
//chrome fixes
var isChrome = sayswho().toLowerCase().indexOf("chrome") >= 0;
var isSafariDesktop = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
var isSafariTablet = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'tablet';
var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
var isIE9 = sayswho() == "MSIE 9";
var isFirefox = (sayswho().toLowerCase().indexOf("firefox") >= 0);
if (isChrome) {
debug.log('applying Chrome page fixes');
diff_height = (current_page_type == 'letter') ? 0 : +4;
}
//safari desktop header/footer fix:
//SAFARI DESKTOP FIXES
if (isSafariDesktop) {
debug.log('applying Safari page fixes');
diff_height = (current_page_type == 'letter') ? -15 : -7;
}
//modern IE (10,11 and so on)
if (isIE || isIE9) {
debug.log('applying IE page fixes');
diff_height = (current_page_type == 'letter') ? 0 : +5;
}
//IPAD SAFARI FIXES
if (isSafariTablet) {
debug.log('applying iPad page fixes');
diff_height = (current_page_type == 'letter') ? +8 : +15;
}
//FIREFOX FIXES
if (isFirefox) {
debug.log('applying FireFox page fixes');
diff_height = (current_page_type == 'letter') ? +5 : +10;
}
page_width = page_width + diff_width;
page_height = page_height + diff_height;
var ret = { width: page_width, height: page_height };
debug.log('page WxH=' + page_width + 'x' + page_height + '(' + diff_width + ',' + diff_height + ')');
return ret;
}
//DZ 10sep14: new method - everything happens inside
//params:
//half_or_full_page = 'half' or 'full'
//duplex_or_page_num: 'duplex'/1/2
function print_card(half_or_full_page, duplex_or_page_num, top_succ_func) {
//rendering quality:
//var canvasW = 1400;
//var canvasW = 1620;
//TODO: same render width for all cases? can be optimized here.
var canvasW = config_render.card_print_width;
var t = $('.editorFrame:visible:first');
var ratio = t.height() / t.width();
var canvasH = parseInt(canvasW * ratio);
debug.log('==== PRINT CARD STARTED: ' + half_or_full_page + 'Page \\index.html ' + duplex_or_page_num + ' on ' + current_page_type + ' page');
var isDuplex = duplex_or_page_num == 'duplex';
var page_dims = get_print_page_dims();
var page_width = page_dims.width;
var page_height = page_dims.height;
//actual layouting:
var isHalfPageLayout = half_or_full_page == 'half';
//(in full page layout remember that card images already come rotated)
//DZ 29jan15: spliting to if
//var img_width = (isHalfPageLayout) ? 90 : 175;
//var img_height = (isHalfPageLayout) ? img_width * ratio : img_width / ratio;
var img_width;
var img_height;
if (isHalfPageLayout) {
img_width = 90;
img_height = img_width * ratio;
}
else {
img_width = 175;
//DZ 29jan15: trying to test round nubmers for card printing quality
img_height = precise_round(img_width / ratio, 1);
}
//DZ 27nov14: square POC:
if ($('body').hasClass('layout_square')) {
//DZ 15feb15: no more half page layout for cards, and square cards are now 5" instead of 5.23inch
//img_width = (isHalfPageLayout) ? 90 : 133;
img_width = 127;
img_height = img_width;
}
else if ($('body').hasClass('layout_landscape')) {
ratio = 1 / ratio;
img_width = (isHalfPageLayout) ? 95 : 177;
img_height = (isHalfPageLayout) ? img_width * ratio : img_width / ratio;
}
//helper method - this method returns a page with 2 images (front/back or mid1/mid2 sides)
//will automatically rotate images if needed (in full page mode)
var func_generate_page_for_printing = function (designerFrame1, designerFrame2, rotationDegrees, succFunc) {
if (succFunc == null) debug.error("NULL SUCC-FUNC");
if (designerFrame2 == null) debug.error('generate_page_for_printing: no frame2 specified');
var newPage = $('');
var rotationDegrees1;
var rotationDegrees2;
//DZ 15dec14: allowing 2 different rotations for input. needed for landscape rotations
if (!jQuery.isArray(rotationDegrees)) {
rotationDegrees1 = rotationDegrees;
rotationDegrees2 = rotationDegrees;
}
else {
rotationDegrees1 = rotationDegrees[0];
rotationDegrees2 = rotationDegrees[1];
}
render_image_from_frame(designerFrame1, canvasW, canvasH, function (imgData) {
get_rotated_image_helper(imgData, rotationDegrees1, function (imgData) {
newPage.append($('
![]()
').css({ width: img_width + 'mm', height: img_height + 'mm' }).addClass('rendered_canvas').attr('src', imgData));
render_image_from_frame(designerFrame2, canvasW, canvasH, function (imgData) {
get_rotated_image_helper(imgData, rotationDegrees2, function (imgData) {
newPage.append($('
![]()
').css({ width: img_width + 'mm', height: img_height + 'mm' }).addClass('rendered_canvas').attr('src', imgData));
//one last thing: if curent page is a4, we set '.page''s width to a4 (set to letter in css)
newPage.css('width', page_width + 'mm');
succFunc(newPage);
});
});
});
});
}
//helper method - receives a Page element with 2 imgs and layouts the images according to page size, and print type
var func_layout_page = function (newPage, isSecondPage) {
var margin_side_name;
//left/right: all are 50%
if (!isSecondPage) {
newPage.find('img').css('left', '50%');
margin_side_name = 'margin-left';
//first page only: border across front img
newPage.find('img:last').css('outline', '1pt solid #aaaaaa');
}
else {
newPage.find('img').css('right', '50%');
margin_side_name = 'margin-right';
}
//top1,top2, margin side value:
var top1;
var top2;
if (isHalfPageLayout) {
top1 = 22; //(page_height - img_height) / 2;
top2 = top1;
margin_side_value1 = -img_width;
margin_side_value2 = 0;
}
else {
top1 = (page_height - (img_height * 2)) / 2;
top2 = top1 + img_height;
margin_side_value1 = -(img_width / 2);
margin_side_value2 = margin_side_value1;
}
var isChrome = (sayswho().toLowerCase().indexOf("chrome") >= 0);
var isFirefox = (sayswho().toLowerCase().indexOf("firefox") >= 0);
var isSafariTablet = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'tablet';
var isSafariDesktop = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
var isIE9 = sayswho() == "MSIE 9";
if (isDuplex) // duplex_or_page_num == 'duplex')
{
if (!isSecondPage) {
//FIRST PAGE FIXES
if (isSafariTablet) {
var safariVersion = sayswho_majorVersion();
//alert("safariVersion is " + safariVersion);
//DZ 28sep14: from version iOS8.0 there isnt a need for the hotfixes in y-axis.
if (safariVersion >= 8) {
}
else {
//OLD iOS version (iOS 7 and below)
if (current_page_type == 'a4') {
//DZ 11sep14: these numbers tested on A4
//DUPLEX iPad Safari hotfix: from some reason the first page need y offset fix.
top1 = top1 - 19;
top2 = top2 - 19;
}
else {
//DZ 13sep14: letter fixes for iPad/Duplex/Letter:
top1 = top1 + 1;
top2 = top2 + 1;
}
}
}
}
else {
//SECOND PAGE FIXES
//DZ 13sep14: duplex LTR printing needs x offset fix on second page
if (current_page_type == 'letter') {
margin_side_value1 = margin_side_value1 + 1;
margin_side_value2 = margin_side_value2 + 1;
top1 = top1 + 0.5;
top2 = top2 + 0.5;
if (isChrome) {
margin_side_value1 = margin_side_value1 - 2;
margin_side_value2 = margin_side_value2 - 2;
}
//DZ 13sep14: firefox duplex letter needs additional fix
else if (isFirefox) {
margin_side_value1 = margin_side_value1 - 3;
margin_side_value2 = margin_side_value2 - 3;
}
else if (isSafariDesktop) {
top1 = top1 - 1;
top2 = top2 - 1;
margin_side_value1 = margin_side_value1 - 2;
margin_side_value2 = margin_side_value2 - 2;
}
else if (isSafariTablet) {
margin_side_value1 = margin_side_value1 - 2;
margin_side_value2 = margin_side_value2 - 2;
}
else if (isIE || isIE9) {
margin_side_value1 = margin_side_value1 - 2;
margin_side_value2 = margin_side_value2 - 2;
}
}
}
}
else {
//NON DUPLEX cases here
//DZ 28sep14: shuldnt enter here on safariDesktop a4 mode
//if (isSecondPage && !isChrome
if (isSecondPage && !isChrome && !((isSafariDesktop || isSafariTablet))) {
//HOTFIX for all browsers but chrome & safari: (2nd page 'x') values need to be hotfixes in 2 mm:
margin_side_value1 = margin_side_value1 - 1;
margin_side_value2 = margin_side_value2 - 1;
}
//DZ 28sep14: hotfix for IE lettersize (non duplex)
if (isSecondPage && current_page_type == 'letter' && (isIE9 || isIE)) {
margin_side_value1 = margin_side_value1 + 1;
margin_side_value2 = margin_side_value2 + 1;
}
}
newPage.find('img:first').css({ top: top1 + 'mm' });
newPage.find('img:last').css({ top: top2 + 'mm' });
newPage.find('img:first').css(margin_side_name, margin_side_value1 + 'mm');
newPage.find('img:last').css(margin_side_name, margin_side_value2 + 'mm');
}
//print page 1:
var func_prepare_page1 = function (succFunc) {
var rotationDegrees = isHalfPageLayout ? 0 : 90;
//DZ15dec14: for landscape mode we switch cards order
var isLandscape = getLayout() == "landscape";
if (isLandscape) {
rotationDegrees = isHalfPageLayout ? [90, 270] : [180, 0]; //first will be90, next will be 270
}
func_generate_page_for_printing($('.tabBack .editorFrame'), $('.tabFront .editorFrame'), rotationDegrees, function (newPage) {
func_layout_page(newPage, false);
succFunc(newPage);
});
};
//print page 2:
var func_prepare_page2 = function (succFunc) {
var rotationDegrees = isHalfPageLayout ? 0 : 270;
if ($('body').hasClass('layout_landscape')) {
rotationDegrees = isHalfPageLayout ? 270 : 180;
}
//DZ15dec14: for landscape mode we switch cards order
//var isLandscape = getLayout() == "landscape";
//var cLeft = !isLandscape ? $('.tabInside .editorFrame:nth-child(2)') : $('.tabInside .editorFrame:first');
//var cRight = !isLandscape ? $('.tabInside .editorFrame:first') : $('.tabInside .editorFrame:nth-child(2)') ;
var cLeft = $('.tabInside .editorFrame:nth-child(2)');
var cRight = $('.tabInside .editorFrame:first');
func_generate_page_for_printing(cLeft, cRight, rotationDegrees, function (newPage) {
func_layout_page(newPage, true);
succFunc(newPage);
});
};
//resetting possible preivous class:
$('#print_contents').empty();
if (duplex_or_page_num == 1) {
func_prepare_page1(function (newPage) {
$('#print_contents').append(newPage);
//DZ 11mar18: SAM code merge
if (editorAppMode==='SAM')
top_succ_func();
else
{
//DZ 26oct15: on chrome empty boxes appears instead of images. this seems to fix this weird caching (?) issue
setTimeout(function () {
window.print();
top_succ_func();
}, 500);
}
});
}
else if (duplex_or_page_num == 2) {
func_prepare_page2(function (newPage) {
$('#print_contents').append(newPage);
//DZ 11mar18: SAM code merge
if (editorAppMode==='SAM')
top_succ_func();
else
{
//DZ 26oct15: on chrome empty boxes appears instead of images. this seems to fix this weird caching (?) issue
setTimeout(function () {
window.print();
top_succ_func();
}, 500);
}
});
}
else {
//duplex printing
func_prepare_page1(function (newPage) {
$('#print_contents').append(newPage);
func_prepare_page2(function (newPage) {
$('#print_contents').append(newPage);
//DZ 11mar18: SAM code merge
if (editorAppMode==='SAM')
top_succ_func();
else
{
//DZ 26oct15: on chrome empty boxes appears instead of images. this seems to fix this weird caching (?) issue
setTimeout(function () {
window.print();
top_succ_func();
}, 500);
}
});
});
}
}
//DZ 11mar18: SAM code merge
//DZ 21dec17: adding postRenderSuccFunc for SAM
//function print_invitation(num_per_page) {
function print_invitation(num_per_page, postRenderSuccFunc) {
debug.log("=== PRINTING " + num_per_page + " per page ===");
desLogic.mark_as_clean();
desLogic.close_popups_or_drawers();
now_loading_start();
//A4 is 210xx297
//LTR is 216x279
//A4 settings:
var page_width = 210;
var page_height = 297;
//ALWAYS PRINTING IN LETTER SIZE
if (true || current_page_type == "letter") {
page_width = 216;
page_height = 279;
}
//safari desktop header/footer fix:
var isSafari = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
var should_fix_page_height = isSafari;
if (should_fix_page_height) {
debug.log('print page height fix for safari. from ' + page_height + ' to ' + (page_height - 20));
page_height = page_height - 32;
}
//canvas size = rendering quality
var t = $('.editorFrame:visible:first');
var ratio = t.height() / t.width();
var canvasW = config_render.invitation_print_width;
var canvasH = canvasW * ratio;
//$(".decor_watermark").show();
if (!desLogic.isOFBConnected()) $(".decor_watermark").show();
render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (imgDataInvitation) {
if (!desLogic.isOFBConnected()) $(".decor_watermark").hide();
//$(".decor_watermark").hide();
var imgInvitation = $('
![]()
').addClass('rendered_canvas').attr('src', imgDataInvitation);
//console.log('---image rendered to length ' + imgDataInvitation.length, canvasW, canvasH);
var newPage = $('
').addClass('invitations_layout');
//SUCC FUNC:
var methodSuccFunc = function () {
$('#print_contents')
.empty()
.append(newPage);
//DZ 11mar18: merge SAM code
//DZ 21dec17: no need to call print on SAM, just to ready up the HTML
if (editorAppMode === "SAM")
{
now_loading_stop();
//SAM 21dec17 hotfix (?): TOOD_ if works move to be done once
// var cloned = $('#section_to_print').clone();
// $('#section_to_print').remove();
// $('#section_to_print_container').append(cloned);
if (postRenderSuccFunc)
postRenderSuccFunc();
}
else
{
//DZ 26oct15: on chrome empty boxes appears instead of images. this seems to fix this weird caching (?) issue
setTimeout(function () {
window.print();
now_loading_stop();
}, 500);
}
};
var isLandscapeLayout = getLayout() == "landscape";
if (num_per_page == 1) {
if (!isLandscapeLayout) {
var img_width = 174;
var img_height = img_width * ratio;
var img_left = (page_width - img_width) / 2;
var img_top = (page_height - img_height) / 2;
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
methodSuccFunc();
}
else {
var img_width = 174;
var img_height = img_width / ratio;
var img_left = (page_width - img_width) / 2;
var img_top = (page_height - img_height) / 2;
get_rotated_image_helper(imgInvitation.attr('src'), 90, function (imgDataInvitation) {
var imgInvitation = $('
![]()
').addClass('rendered_canvas').attr('src', imgDataInvitation);
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
methodSuccFunc();
});
}
}
else if (num_per_page == 2) {
if (!isLandscapeLayout) {
get_rotated_image_helper(imgInvitation.attr('src'), 90, function (imgDataInvitation) {
var imgInvitation = $('
![]()
').addClass('rendered_canvas').attr('src', imgDataInvitation);
//remember that its rotated here. dont get confused because width=height etc
//YZ 23-5-19 : changing from 175
var img_width = 177.8; //~7inch
if ($('body').hasClass('layout_square'))
img_width = 127; //YZ 23-5-19 : changing from 130
var img_height = img_width / ratio;
var img_left = (page_width - img_width) / 2;
var img_top = (page_height - (img_height * 2)) / 2;
debug.log(img_width, img_height, img_left, img_top);
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + 'mm' }));
methodSuccFunc();
});
}
else {
//landscape layout: 1 under the other, no rotation
var img_width = 177.8; //~7inch
var img_height = img_width * ratio;
var img_left = (page_width - img_width) / 2;
var img_top = (page_height - (img_height * 2)) / 2;
debug.log(img_width, img_height, img_left, img_top);
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + 'mm' }));
methodSuccFunc();
}
}
else if (num_per_page == 4) {
if (!isLandscapeLayout) {
var img_width = 87;
var img_height = img_width * ratio;
var img_left = (page_width - (img_width * 2)) / 2;
var img_top = (page_height - (img_height * 2)) / 2;
debug.log(img_width, img_height, img_left, img_top);
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + img_width + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + img_width + 'mm' }));
methodSuccFunc();
}
else {
get_rotated_image_helper(imgInvitation.attr('src'), 90, function (imgDataInvitation) {
var imgInvitation = $('
![]()
').addClass('rendered_canvas').attr('src', imgDataInvitation);
var img_width = 87;
var img_height = img_width / ratio;
var img_left = (page_width - (img_width * 2)) / 2;
var img_top = (page_height - (img_height * 2)) / 2;
debug.log(img_width, img_height, img_left, img_top);
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + 'mm', left: img_left + img_width + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + 'mm' }));
newPage.append(imgInvitation.clone().css({ width: img_width + 'mm', height: img_height + 'mm', top: img_top + img_height + 'mm', left: img_left + img_width + 'mm' }));
methodSuccFunc();
});
}
}
//this CSS class will take care of positioniong
//newPage.addClass('invitations_layout').addClass('invitations_layout_' + num_per_page)
});
}
//var TO_RADIANS = Math.PI / 180;
function canvasDrawRotatedImage(context, image, x, y, width, height, angle) {
//DZ 19jul15: fixing rotation issues (also in params x,y - offset calculation affected by rotation in render_decor_to_canvas)
//OLD CODE:
//context.save();
////context.globalAlpha = 0.4;
//context.translate(x + (width / 2), y + (height / 2));
//context.rotate(angle * Math.PI / 180);
//context.drawImage(image, -width / 2, -height / 2, width, height);
////context.rotate(-angle * Math.PI / 180);
////context.translate(-x - (width / 2), -y - (height / 2));
//context.restore();
//NEW CODE:
context.save();
context.translate(x, y);
context.rotate(angle * Math.PI / 180);
context.drawImage(image, 0, 0, width, height);
context.restore();
}
function get_rotation_degress_of_element(thisDecor) {
//rotation degrees(30) is returned as matrix - figuring out degress here: (if any)
//var tr = thisDecor.css('transform').indexOf('matrix') >= 0 ? thisDecor.css('transform') : jqTextArea.css('transform');
var rotationDegress = 0;
//var tr = thisDecor.css('transform');
//DZ 17may15: fixing safari issue with rotation
//console.log("========= IN METHOD ===========", thisDecor.css('transform'), thisDecor.css('-webkit-transform'));
var tr = thisDecor.css('transform');
if (tr == null) tr = thisDecor.css('-webkit-transform');
if (tr.indexOf('matrix') >= 0) {
var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0];
var b = values[1];
var c = values[2];
var d = values[3];
rotationDegress = Math.atan2(b, a) * (180 / Math.PI);
}
return rotationDegress;
}
//better downscaling then JS canvas.
//adapted from http://jsfiddle.net/gamealchemist/kpQyE/3/, found in thread http://stackoverflow.com/questions/18922880/html5-canvas-resize-downscale-image-high-quality
// scales the image by (float) scale < 1
// returns a canvas containing the scaled image.
//high quality, but doesnt support transparency
function downScaleImage(img, scale) {
var imgCV = document.createElement('canvas');
imgCV.width = img.width;
imgCV.height = img.height;
var imgCtx = imgCV.getContext('2d');
imgCtx.drawImage(img, 0, 0);
return downScaleCanvas(imgCV, scale);
}
// scales the canvas by (float) scale < 1
// returns a new canvas containing the scaled image.
function downScaleCanvas(cv, scale) {
if (!(scale < 1) || !(scale > 0)) throw ('scale must be a positive number <1 ');
var sqScale = scale * scale; // square scale = area of source pixel within target
var sw = cv.width; // source image width
var sh = cv.height; // source image height
var tw = Math.ceil(sw * scale); // target image width
var th = Math.ceil(sh * scale); // target image height
var sx = 0, sy = 0, sIndex = 0; // source x,y, index within source array
var tx = 0, ty = 0, yIndex = 0, tIndex = 0; // target x,y, x,y index within target array
var tX = 0, tY = 0; // rounded tx, ty
var w = 0, nw = 0, wx = 0, nwx = 0, wy = 0, nwy = 0; // weight / next weight x / y
// weight is weight of current source point within target.
// next weight is weight of current source point within next target's point.
var crossX = false; // does scaled px cross its current px right border ?
var crossY = false; // does scaled px cross its current px bottom border ?
var sBuffer = cv.getContext('2d').
getImageData(0, 0, sw, sh).data; // source buffer 8 bit rgba
var tBuffer = new Float32Array(4 * sw * sh); // target buffer Float32 rgb
var sR = 0, sG = 0, sB = 0; // source's current point r,g,b
// untested !
var sA = 0; //source alpha
for (sy = 0; sy < sh; sy++) {
ty = sy * scale; // y src position within target
tY = 0 | ty; // rounded : target pixel's y
yIndex = 4 * tY * tw; // line index within target array
crossY = (tY != (0 | ty + scale));
if (crossY) { // if pixel is crossing botton target pixel
wy = (tY + 1 - ty); // weight of point within target pixel
nwy = (ty + scale - tY - 1); // ... within y+1 target pixel
}
for (sx = 0; sx < sw; sx++, sIndex += 4) {
tx = sx * scale; // x src position within target
tX = 0 | tx; // rounded : target pixel's x
tIndex = yIndex + tX * 4; // target pixel index within target array
crossX = (tX != (0 | tx + scale));
if (crossX) { // if pixel is crossing target pixel's right
wx = (tX + 1 - tx); // weight of point within target pixel
nwx = (tx + scale - tX - 1); // ... within x+1 target pixel
}
sR = sBuffer[sIndex]; // retrieving r,g,b for curr src px.
sG = sBuffer[sIndex + 1];
sB = sBuffer[sIndex + 2];
sA = sBuffer[sIndex + 3];
if (!crossX && !crossY) { // pixel does not cross
// just add components weighted by squared scale.
tBuffer[tIndex] += sR * sqScale;
tBuffer[tIndex + 1] += sG * sqScale;
tBuffer[tIndex + 2] += sB * sqScale;
tBuffer[tIndex + 3] += sA * sqScale;
} else if (crossX && !crossY) { // cross on X only
w = wx * scale;
// add weighted component for current px
tBuffer[tIndex] += sR * w;
tBuffer[tIndex + 1] += sG * w;
tBuffer[tIndex + 2] += sB * w;
tBuffer[tIndex + 3] += sA * w;
// add weighted component for next (tX+1) px
nw = nwx * scale
tBuffer[tIndex + 4] += sR * nw; // not 3
tBuffer[tIndex + 5] += sG * nw; // not 4
tBuffer[tIndex + 6] += sB * nw; // not 5
tBuffer[tIndex + 7] += sA * nw; // not 6
} else if (crossY && !crossX) { // cross on Y only
w = wy * scale;
// add weighted component for current px
tBuffer[tIndex] += sR * w;
tBuffer[tIndex + 1] += sG * w;
tBuffer[tIndex + 2] += sB * w;
tBuffer[tIndex + 3] += sA * w;
// add weighted component for next (tY+1) px
nw = nwy * scale
tBuffer[tIndex + 4 * tw] += sR * nw; // *4, not 3
tBuffer[tIndex + 4 * tw + 1] += sG * nw; // *4, not 3
tBuffer[tIndex + 4 * tw + 2] += sB * nw; // *4, not 3
tBuffer[tIndex + 4 * tw + 3] += sA * nw; // *4, not 3
} else { // crosses both x and y : four target points involved
// add weighted component for current px
w = wx * wy;
tBuffer[tIndex] += sR * w;
tBuffer[tIndex + 1] += sG * w;
tBuffer[tIndex + 2] += sB * w;
tBuffer[tIndex + 3] += sA * w;
// for tX + 1; tY px
nw = nwx * wy;
tBuffer[tIndex + 4] += sR * nw; // same for x
tBuffer[tIndex + 5] += sG * nw;
tBuffer[tIndex + 6] += sB * nw;
tBuffer[tIndex + 7] += sA * nw;
// for tX ; tY + 1 px
nw = wx * nwy;
tBuffer[tIndex + 4 * tw] += sR * nw; // same for mul
tBuffer[tIndex + 4 * tw + 1] += sG * nw;
tBuffer[tIndex + 4 * tw + 2] += sB * nw;
tBuffer[tIndex + 4 * tw + 3] += sA * nw;
// for tX + 1 ; tY +1 px
nw = nwx * nwy;
tBuffer[tIndex + 4 * tw + 4] += sR * nw; // same for both x and y
tBuffer[tIndex + 4 * tw + 5] += sG * nw;
tBuffer[tIndex + 4 * tw + 6] += sB * nw;
tBuffer[tIndex + 4 * tw + 7] += sA * nw;
}
} // end for sx
} // end for sy
// create result canvas
var resCV = document.createElement('canvas');
resCV.width = tw;
resCV.height = th;
var resCtx = resCV.getContext('2d');
var imgRes = resCtx.getImageData(0, 0, tw, th);
var tByteBuffer = imgRes.data;
// convert float32 array into a UInt8Clamped Array
var pxIndex = 0; //
for (sIndex = 0, tIndex = 0; pxIndex < tw * th; sIndex += 4, tIndex += 4, pxIndex++) {
tByteBuffer[tIndex] = Math.ceil(tBuffer[sIndex]);
tByteBuffer[tIndex + 1] = Math.ceil(tBuffer[sIndex + 1]);
tByteBuffer[tIndex + 2] = Math.ceil(tBuffer[sIndex + 2]);
tByteBuffer[tIndex + 3] = Math.ceil(tBuffer[sIndex + 3]);
}
// writing result to canvas.
resCtx.putImageData(imgRes, 0, 0);
return resCV;
};
//--- GLOBALS ---
var OnlineSender = null;
var inMobileMode = false; //changecd on Editor.mobile.js
var browser_category = categorizr();
//DZ 7dec14: Win8.1, IE11 fix, recognized as tablet. hotfixing to force desktop mode.
if (sayswho() == "IE 11")
browser_category = "desktop";
//DZ 11oct15: removing watermark when rendering for ordered print
var now_rendering_without_watermark = false;
//SIZES FO BACKGROUND IMAGES USED:
//CARD PORTRAIT - 1080 x 1560 (1 : 1.4444)
//CARD SQUARE - 1000 x 1000 (1 : 1)
//INVITATION PORTRAIT - 1080 x 1560 (1 : 1.4444)
//INVITATION SQUARE - 1000 x 1000 (1 : 1)
//INVITATION LANDSCAPE - 1400 x 1000 (1.4 : 1)
var config_render = {
//each ecard preview frame - all those widths mark a single frame (e.g. cards have 4 frames, invitation has 1, ecard has 2)
card_print_summary_width: 300,
card_print_width: 1620,
card_pdf_width: 1500,
invitation_pdf_width: 3000,
//DZ 11mar18: SAM merge (used to be value, now array. wasnt updated in SAM)
invitation_jpeg_width: {
//portrait: 1500, square: 1500, landscape: 2166
portrait: 3000, square: 3000, landscape: 4200
},
invitation_print_width: 2160,
//DZ REDESIGN 26jan16: changed to 380 from 1480
ecard_preview_width: 380,
//DZ 26jan17: no longer resizes! but actual sizes of render (wrong naming)
ecard_resize_to_fb_share: 1480,
ecard_resize_to_email: 1480,
ecard_resize_to_pdf: 1840, //DZ 29jan15: changed to 2960 from 2400
ecard_resize_to_jpeg: 1840,
//YZ 7/2/17 - Setting different width for invites and cards.
send_online_width: { invitations: { "portrait": 1296, "square": 954, "landscape": 1500 }, cards: { "portrait": 750, "square": 1083, "landscape": 1500 } }
//DZ 11mar18: SAM code merge
//DZ 20sep18: review w/Yair - not required anymore
//3d cards previews (for render, always the desktop size is being used):
// preview3d_portrait: {desktop:750,mobile:375},
// preview3d_square: { desktop: 1083, mobile: 512 },
// preview3d_landscape: { desktop: 1500, mobile: 375 }
};
//DZ 9feb15: custom ipad config for memory issues:
if (browser_category == "tablet") {
config_render.invitation_print_width = 1440;
config_render.ecard_resize_to_jpeg = 1850;
config_render.ecard_resize_to_pdf = 1850;
}
//DZ 27apr15: custom iphoen memory issues (detected on rotation when printing 2 invitations)
else if (browser_category == "mobile") {
config_render.invitation_print_width = 1440;
}
//DZ 17aug14: solves global error on jquery.js for debug.log (..\\http\\stackoverflow.com\\questions\\3326650\\MS_7797.html)
if (!window.console) console = { log: function () { }, error: function () { } };
var isIE9 = sayswho() == "MSIE 9";
var displayErrorsAsAlerts = false;
var last_drag_datetime = 0;
var is_admin_mode = false;
function markDragEnd() { last_drag_datetime = (new Date()).getTime(); }
function isDrag() { return (new Date()).getTime() - last_drag_datetime < 50 || (inMobileMode && window.now_scrolling); }
//DZ 27mar17: for fixing dragging in scaled divs (see http://stackoverflow.com/questions/13882070/jquery-draggable-and-webkit-transform-scale)
var lastDragStartPos = {
x: 0,
y: 0
};
var renderDimensions = { production: 0, preview: 1, sample: 2, thumbnail: 3, einvitation: 4 };
//genereic ajax error handler
//DZ 1jul18: this can be removed - not used anymore
// function ajax_error_handler(jqXHR, textStatus, errorThrown) {
// debug.error('AJAX ERROR', { 'jqXHR': jqXHR, 'textStatus': textStatus, 'errorThrown': errorThrown });
// }
//generic ajax error handler + popup message
function ajax_show_error_popup_handler(jqXHR, textStatus, errorThrown, message) {
try {
debug.error('AJAX ERROR', { 'jqXHR': jqXHR, 'textStatus': textStatus, 'errorThrown': errorThrown });
desLogic.show_unexpected_error_msg(message);
}
catch (e) {
//just in case
console.error("failed INSIDE ajax_show_error_popup_handler", jqXHR, textStatus, errorThrown, message)
}
now_loading_stop();
}
//should add 'move' handle on freesize textbox only on mobile
//DZ 27mar17 REDMOB - not showin those anymore
//var should_have_move_handle_on_freesize_text_slots = browser_category == "mobile" || browser_category == "tablet" || getParameterByName('forcemobile') != '';
var should_have_move_handle_on_freesize_text_slots = false;
//should add 'delete' handle on freesize: only on cards
//DZ 11mar18: merge from SAM:
//DZ 5dec17: SAM - no editor_mode var when this loads - might cause issues (solve later)
//SAM VERSION: var should_have_trash_handle_on_freesize_text_slots = true;
//WEB VERSION: var should_have_trash_handle_on_freesize_text_slots = editorMode == 'invitations'; //later changed if is_admin_mode
var should_have_trash_handle_on_freesize_text_slots = (editorAppMode === "SAM") || editorMode == 'invitations'; //later changed if is_admin_mode
//--- GLOBALS UNTIL HERE ---
//this controller manages eveyrthing inside the "designed" area (not UX specific to desktop or mobile)
function DesignerLogic() {
var thisController = this;
var changed_flag;
//will hold all stickers, according to category
//public
this.all_stickers_by_category = null;
//PUBLIC - will hold the current textarea now being designed:
this.text_design_popup_current_target = null;
this.text_design_popup_revert_data = null;
//PUBLIC - will hold the current slot_phot now being designed:
this.context_slot_photo = null;
this.context_slot_photo_revert_data = null;
this.context_slot_photo_reverted_image_src = null;
this.context_slot_photo_reverted_unfiltered_src = null;
//will conntain the various possible layouts
var jsonLayouts;
//will contain last successfull save name (to skip savename dialog)
//public
this.context_save_name = null;
//Used for online invites: contains URL of online invite so it will not regenerate every time
var online_invite_public_url = null;
//DZ 13aug14: if font size was changed because of text entry, then dont revert it
this.mark_this_text_font_size_as_non_revetable = function () {
if (desLogic.text_design_popup_revert_data != null)
desLogic.text_design_popup_revert_data.font_size_unrevertable = true;
}
//PUBLIC - used in mobile
this.editor_scale = 1.00;
//current FB access token
var fb_user_axx_token;
//min font size in slider
//var SLIDER_MIN_FONT_SIZE = 13;
//DZ 21may17
var SLIDER_MIN_FONT_SIZE = 10;
//DZ 1dec16: new font load system
var fontsAlreadyLoaded = new Array();
//DZ 12mar18: added this (from SAM) - because no Lato.css exists, and Lato is already loaded.
if (editorAppMode == 'SAM')
fontsAlreadyLoaded.push('Lato');
//24jul17: premium remove watermark - set only if user had paid (after API check)
//PRIVATE!
var premium_watermark_removal_was_paid = false;
//public - obfoscated name (+..\\-.html) - really returns watermark paid for (after a previous API check)
this.isOFBConnected = function () { return premium_watermark_removal_was_paid; }
this.init = function () {
reposition_some_shared_html();
init_editor_shared_ux();
//DZ 16mar17: used to be called initEvents
initEditorEvents();
}
//DZ 25jul17:
//public
this.show_unexpected_error_msg = function (message) {
desLogic.close_popups_or_drawers();
if (!inMobileMode) {
//uxController.close_all_popups();
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("unexpected_error"), getLocCaption("unexpected_error_desc") + (message ? '
' + message + '' : ''), getLocCaption("Close"));
uxController.show_popup_centered($('#popup_simple_template'));
}
else {
uxController.bind_simple_drawer("popup_with_close_btn", getLocCaption("unexpected_error"), getLocCaption("unexpected_error_desc") + (message ? '
' + message + '' : ''), getLocCaption("Done"));
}
}
//private - repositions stuff from shared html
function reposition_some_shared_html() {
//finish modals are shared in shared.cshtml - so here we move them to their rightful place
//private inner method - appends element from anywhere to body or the appropriate modal/popup container
function repositionFromShared(cssSelector, isToModalsContainer) {
var cloned = $(cssSelector).clone();
$(cssSelector).remove();
if (!isToModalsContainer)
$('body').append(cloned);
else {
var jqTarget = inMobileMode ? $('#modals-container') : $('#editor_popups_container');
jqTarget.append(cloned);
}
}
repositionFromShared('#popup_finish_tabs', true);
repositionFromShared('#popup_finish_tabs_cards', true);
repositionFromShared('#popup_thanks_for_sending', true);
repositionFromShared('#section_to_print', false);
repositionFromShared('#popup_facebook_photo_upload', true);
repositionFromShared('#popup_text_in_margins', true);
repositionFromShared('#popup_share_us', true);
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'cards' || editorMode == 'ecards_v2') {
if (editorMode == 'cards' || editorMode == 'ecards') {
//DZ 11sep17: repositioning "Send Online" finish tab from invitation to cards modal:
//DZ 11sep17: cloning the entire "send online" part from Invitation's finish
var cloned = $('#finish_tab_invi_share').clone();
$('#finish_tab_invi_share').remove();
$('#popup_finish_tabs_cards .tab-content-section').append(cloned);
//change order for ecards_v2:
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards_v2') {
if (editorMode == 'ecards') {
//change order of tabs:
$("#popup_finish_tabs_cards .tabs-nav li:nth-child(1)").before($("#popup_finish_tabs_cards .tabs-nav li:nth-child(3)"));
//change order in tab contents:
$("#finish_tab_cards_print").before($("#finish_tab_invi_share"));
$('#popup_finish_tabs_cards .tabs-nav .active, #popup_finish_tabs_cards .tab-content.active').removeClass('active');
$('#popup_finish_tabs_cards .tabs-nav li:nth-child(1),#finish_tab_invi_share').addClass('active');
//DZ 25sep17: fixin'
$('#popup_finish_tabs_cards .preview-section').addClass('preview-section-shown');
}
}
}
this.mark_as_dirty = function () {
thisController.changed_flag = true;
};
this.mark_as_clean = function () {
thisController.changed_flag = false;
};
//DZ 9apr17: moving those to Editor.Shared.js from main.js
function general_html_inits_from_andru() {
//DZ 25jan18: those tabs are not clickable anymore (design change)
$('.tabs .tabs-nav').on('click', 'li:not(.active)', function () {
//DZ 11jul17: faster fadein (from 250 to 50)
$(this).addClass('active').siblings().removeClass('active')
.closest('.tabs').find('.tab-content').hide().eq($(this).index()).fadeIn(100);
//DZ 5jul17 - new finish layout: also calling thisController.func_update_invitations_preview_panel
//invitations:
//this is for invitations:
if (thisController.func_update_invitations_preview_panel)
thisController.func_update_invitations_preview_panel();
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//else if (editorMode == 'cards' || editorMode == 'ecards_v2') {
else if (editorMode == 'cards' || editorMode == 'ecards') {
//for 'finish share' tab we show a different preview:
//console.log('doing it doing it', $(this), $(this).attr('id'), $(this).attr('data-tab-name'));
//DZ 7feb18: attr('id') doesnt work from some reason
//$('#popup_finish_tabs_cards .preview-section').toggleClass('preview-section-shown', $(this).attr('id') == 'send_online_tab_link');
$('#popup_finish_tabs_cards .preview-section').toggleClass('preview-section-shown', $(this).attr('data-tab-name') == 'share');
}
//23jul17: after changing Finish_cards layout: also hiding preview-section if not first step
$('#popup_finish_tabs_cards').removeClass('showing-full-width-instructions');
});
// finish layout options: select invitation per paper
$(".layout-options").on("click", ".layout-option", function () {
$(this).addClass("-active").siblings().removeClass("-active");
});
// toggle download pdf options
$('[name="download_type"]').on("change", function () {
//console.log($("#download-pdf-radio").is(':checked'));
$("#download-pdf-options").toggleClass("-show-options", $("#download-pdf-radio").is(':checked'));
});
// updates the text on link tooltip
//$(".copy-to-clipboard").on("click", function () {
// if (!inMobileMode)
// $(this).qtip('option', 'content.text', $(this).data("text-copied"));
// else
// //Mobile:
// alert('Copied to clipboard!');
//});
// checkbox checked shows more options
$('.toggle-options-trigger').on("click", function () {
var
$this = $(this),
target = $this.data("toggle-options"),
$checkbox = $this.find('input[type="checkbox"]');
if ($checkbox.is(":checked")) {
$(target).slideDown();
} else {
$(target).slideUp();
}
});
//toggle elements on the page via data-next-step & data-prev-step
$("[data-next-step]").on("click", function () {
var target = $(this).data("next-step");
$(this).closest(".finish-step").hide();
$(target).show();
//23jul17: adding to this handler - after changing Finish_cards layout: also hiding preview-section if not first step
//console.log("checking it", target, target != '#print-settings');
$('#popup_finish_tabs_cards').toggleClass('showing-full-width-instructions', target != '#print-settings' && target != '#invitation-send-via-email');
//DZ 27jul17: making the 'item-actions' (which is tall) not aligned to center on mobile:
if ($('html').hasClass('mobile'))
$('#finish_tab_invi_share .item-actions').toggleClass('not-cent-just', target == '#invitation-send-via-email');
//$('#finish_tab_invi_share .item-actions').css('justify-content', target == '#invitation-send-via-email' ? 'unset' : 'center');
});
$("[data-prev-step]").on("click", function () {
var target = $(this).data("prev-step");
$(this).closest(".finish-step").hide();
$(target).show();
//23jul17: adding to this handler - after changing Finish_cards layout: also hiding preview-section if not first step
$('#popup_finish_tabs_cards').toggleClass('showing-full-width-instructions', target != '#print-settings' && target != '#invitation-share-options');
//DZ 27jul17: making the 'item-actions' (which is tall) not aligned to center on mobile:
if ($('html').hasClass('mobile'))
//$('#finish_tab_invi_share .item-actions').css('justify-content', target == '#invitation-send-via-email' ? 'unset' : 'center');
$('#finish_tab_invi_share .item-actions').toggleClass('not-cent-just', target == '#invitation-send-via-email');
});
}
//PRIVATE - confirm gtfo text
function get_gtfo_text() {
var msg;
switch (editorMode) {
case 'invitations':
msg = localizationDict['exit_intent_warning_invi'];// '@T("You have edited this invitation.")';
break;
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//case 'ecards':
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//case 'ecards_v2':
case 'ecards':
//DZ 11sep17: same message for new ecards_v2
msg = localizationDict['exit_intent_warning_ecard'];// '@T("You have edited this ecard.")';
break;
default:
msg = localizationDict['exit_intent_warning_card'];// '@T("You have edited this card.")';
break;
}
return msg;
}
//public - mobile confirm navigation event:
this.confirmNavForMobile = function (href) {
if (desLogic.changed_flag && $('body').hasClass('now_initing') == false) {
var msg = get_gtfo_text();
if (confirm(msg + '\nDo you want to leave this page?'))
window.location = href;
}
else {
window.location = href;
}
};
//PRIVATE - misc shared inits
function init_editor_shared_ux() {
$('body').addClass('now_initing');
var isSafari = sayswho().indexOf('Safari');
if (isSafari > -1)
$('html').addClass('apple-safari');
general_html_inits_from_andru();
//INITING EVENTS ACCORDING TO cards/invit/ecards
//DZ 11sep17: moved to bind_send_online_finish_tab (now it always happens, after ecards_v2 update)
//if (editorMode !== 'cards')
// bind_send_online_events();
//set debug level:
//DZ 11mar18: SAM code merge
if (editorAppMode === "SAM" || getParameterByName('debug') == '')
debug.setLevel(0);
//cultural variation:
if (currentCulture == "es")
$('body').addClass('locale_spanish');
//DZ 22oct14: at run time, an 'id' attribute will be added to each font span for quick lookups for line_height_multiplier values
//$('#popup_text_style ul.options span').each(function () {
$('#editor-fonts span').each(function () {
var fontName = getFontName($(this).css('font-family'));
var newSpanId = get_font_name_span_id(fontName);
//debug.error('span_id = ' + newSpanId);
$(this).attr('id', newSpanId);
});
//DZ 20mar17: moved here from CSHTML
//confirm navigation:
//DZ 11mar18: SAM code merge
//DZ 11dec17: not doing this on SAM - breaks android look & feel (and not working on iOS)
//if (!is_admin_mode) {
if (!is_admin_mode && editorAppMode !== "SAM") {
var isSafari = sayswho().indexOf('Safari') > -1;
if (inMobileMode && isSafari) {
//MOBILE SAFARI - only on 'back' button (no support for standard method)
var href = $('.back-arrow').attr('href');
$('.back-arrow').attr('href', 'javascript:desLogic.confirmNavForMobile("' + href +'");');
}
else {
//STANDARD - ON ANY LEAVE OF PAGE
window.onbeforeunload = function () {
//DZ 22may18: [OI-4] when we cause navigatation, we might get the "Navigating will erase changes" prompt. here we (hot-)fix this:
var navigationApproved = false;
try {
if (window.approved_navigation_datetime) {
var delta = (new Date()).getTime() - window.approved_navigation_datetime.getTime();
console.log('check approved nav', delta);
if (delta < 1000)
navigationApproved = true;
}
}
catch (e) {
}
if (!navigationApproved && desLogic.changed_flag && $('body').hasClass('now_initing') == false) {
//DZ 8may17: custom message doesnt work anymore with most modern browsers.
var msg = get_gtfo_text();
return msg;
}
};
}
}
//DZ 27nov14: POC for square
if (getLayout() == "square")
$('body').addClass('layout_square');
else if (getLayout() == "landscape")
$('body').addClass('layout_landscape');
//fixing focus on textarea scrolls container (in case of out-of-bounds textareas)
var observe;
if (window.attachEvent) {
observe = function (element, event, handler) {
element.attachEvent('on' + event, handler);
};
}
else {
observe = function (element, event, handler) {
element.addEventListener(event, handler, false);
};
}
$('.editorFrameContainer,.editorFrame').each(function () {
var htmlFrame = this;
observe(htmlFrame, 'scroll', function (e) {
$(htmlFrame).scrollLeft(0).scrollTop(0);
});
});
add_slots_to_editors();
init_image_design_options();
if (editorMode != 'invitations')
bind_layouts();
//DZ 11mar18: SAM code merge:
//DZ 28nov17: this method used to pend window.load (not sure about reason here).
//when adding the SAM support, we also run the same thing with a small timer (otherwise it wouldnt run in SAM mode)
//$(window).bind("load", function(){...});
var loadFunc = function () {
bindFontSelection();
//DZ 1dec16: new font loading mechanism
//WebFontLoaded(fonts_to_wait_for, function () {
loadInitialFonts(function () {
thisController.bind_card_metadata(cardId);
//autosize textarea inputs for text slots (..\\http\\www.jacklmoore.com\\autosize\\MS_7798.html)
//DONE ONLY ONCE - no new custom_textareas once page inited (still true according to 30jun14)
$('.custom_textarea').autosize({ append: '' });
$('.custom_textarea')
//DZ REDMOB - for now calling uxController - should be in desLogic
.keyup(function (e) { thisController.mark_as_dirty(); desLogic.auto_change_textarea_font_size($(e.currentTarget)) })
.focus(function (e) {
if (!inMobileMode)
uxController.text_design_popup_open($(e.currentTarget));
});
//--everything complete, now making sure first image is loaded--
var final_succ_func = function () {
debug.log('load complete');
uxController.post_load_events();
now_loading_stop();
thisController.mark_as_clean();
if (is_admin_mode)
init_admin_edit_page(); //from new_editor.admin.js, loaded only in admin page
//YZ 13-Dec-15:pulishing 'load complete' event to be used outside the designer.
$.publish('designer.loadComplete');
$('body').removeClass('now_initing');
//DZ 1dec16: after everything loaded, we load our postponed data urls for images
$('.post-load').each(function () {
$(this).attr('src', $(this).attr('post-load-src'));
});
//PRELOAD IMAGES:
//these loaded async, after all editor is ready (everything loaded here requires a user interaction, and not part of initial resources needed to show the editor)
};
//DZ 9mar15: warpping in another function, executed after loading user load (if needed)
//this is the really final final func, executed after checking if user load data exists
var preload_image_and_launch_editor = function () {
//DZ 20apr17: removed this. doesnt seem like it optimizes anything anymore. cause image to be loaded twice in mobile, 3 times in desktop (wtf)
//DZ 28oct14: not always has image (as in admin new card scenario):
//if (cardConfig.pages[0].name != null)
// async_create_and_load_image(cardConfig.pages[0].name, final_succ_func);
//else
// final_succ_func();
final_succ_func();
};
//now load user data if needed: (cardDesign holds saved user data, if any)
if (cardDesign == null) {
//DZ 27jun17: this moved to the proper place in the flow of things (CIE-188)
//no saved user card - so we check for "saved order"
if (getParameterByName('orderDesignCode') != '')
//loading saved order:
desLogic.load_json_to_editor(orderDesign.cardDesign, preload_image_and_launch_editor);
else
preload_image_and_launch_editor(); //no saved anything - continuing
}
else {
try {
debug.log('user saved card loaded ', cardDesign);
thisController.context_save_name = cardName;
thisController.load_json_to_editor(cardDesign, preload_image_and_launch_editor);
}
catch (ex) {
debug.error('failed binding JSON - trying to continue', ex);
preload_image_and_launch_editor();
}
}
});
};
//see 28nov17 comment above
if (editorAppMode !== "SAM")
$(window).bind("load", loadFunc)
else
setTimeout(loadFunc, 500);
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards')
// desLogic.change_editor_tab('inside');
initRecipientsEditor();
//STICKERS etc
//clicking sticker brings it to front:
var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchend' : 'click';
$('body').on(eventName, '.sticker_container', function () {
desLogic.bring_sticker_to_front($(this));
desLogic.set_focus($(this));
if (inMobileMode && !isDrag()) {
uxController.close_all_drawers();
}
//console.log('focused!');
});
//delete sticker from sticker border icon
$('body').on(eventName, '.sticker_container .delete', function (ev) {
$(this).parents('.sticker_container').remove();
desLogic.close_popups_or_drawers();
});
$(".editorFrame").droppable({
tolerance: "intersect",
..\\http\\accept\\MS_7799.html ".sticker,.sticker_container",
accept: ".sticker,.sticker_container,.freesize",
drop: function (ev, ui) {
//var originalSticker = $(ui.helper[0]);
//console.log("DROPPED", $(this)[0], ui.helper.context);
var originalSticker = $(ui.helper.context);
if (originalSticker.hasClass('sticker')) {
//making sticker buttons droppable to designer's frames:
debug.log('sticker drop');
var targetFrame = null;
if ($(ev.target).hasClass('editorFrame'))
targetFrame = $(ev.target);
else
targetFrame = $(ev.target).parents('.editorFrame');
if (targetFrame == null || targetFrame.length == 0)
debug.error('bad drop. unknown error');
else {
//saving in pixels, will be later translated to percents (anyway can be draggable and changed to 'px')
//var src = ui.helper.find('img').attr('src');
var src = ui.helper.attr('sticker_url');
//debug.log(src);
var x = ui.offset.left - $(this).offset().left - 48;
var y = ui.offset.top - $(this).offset().top - 48;
//if (thisController.editor_scale != 1)
//{
//console.log('hotfixin scale', x, y);
x += 48 * thisController.editor_scale;
y += 48 * thisController.editor_scale;
x /= thisController.editor_scale;
y /= thisController.editor_scale;
//console.log('hotfixed scale', x, y);
//}
var newStickerContainer = thisController.place_sticker_on_designer(src, targetFrame, (x + 20) + 'px', (y + 20) + 'px');
//not closing drawers
thisController.set_focus(newStickerContainer);
}
}
else if (originalSticker.hasClass('sticker_container')) {
//DZ 3sep14: removing overflow hotfix.
var originalFrame = originalSticker.parents('.editorFrame');
var targetFrame = $(this);
var newLeft = (ui.offset.left - targetFrame.offset().left);
var newTop = (ui.offset.top - targetFrame.offset().top);
//DZ 5apr17: major sticker mobile fix:
newLeft /= desLogic.editor_scale;
newTop /= desLogic.editor_scale;
if (originalFrame.is(targetFrame)) {
//console.log('sticker_container moved inside frame', ev, ui, newLeft,newTop);
originalSticker.css({ left: newLeft + 'px', top: newTop + 'px' });
desLogic.reposition_sticky_handles(originalSticker);
}
//DZ 7jun17: disabling this for mobile. other hotfix invoked on sticker drag() event
if (!inMobileMode && !originalFrame.is(targetFrame)) {
//making stickers droppable from other editor frames (relevant only to inside pages)
//if sticker was dragged to new frame
console.log("MOVING STICKER BETWEEN FRAMES - drop() event");
//some fixes: removing opacity and jqui classes/elements
var newSticker = originalSticker.clone();
newSticker.removeClass('ui-resizable').css('opacity', 'inherit');
newSticker.find('.ui-resizable-handle').remove();
//remove cursor from body
$('body').css('cursor', 'inherit');
newSticker.css({ left: newLeft, top: newTop });
originalSticker.remove();
targetFrame.append(newSticker);
init_sticker_containers(newSticker);
desLogic.reposition_sticky_handles(newSticker);
}
}
}
});
//DZ 5jan17: a better mechanism, for more arrows:
$('.go-editor-tab').click(function () {
//DZ 15may17: changing mechanism here for mobile
var targetTab;
if (!inMobileMode)
targetTab = $(this).attr('target-tab');
else {
//mobile left/right arrows:
var isNext = $(this).is('.-arrow-right');
var currentTabDiv = $('.item-sides .item-side.-active');
if (currentTabDiv.attr('tab') == 'front' || currentTabDiv.attr('tab') == 'back')
targetTab = 'inside';
else
targetTab = isNext ? 'back' : 'front';
}
//DZ 18aug14: button is position same as 3rd page's textbox. so double clicking sometimes causes pausing.
//hotfix:
$('.slot_text textarea').attr('disabled', 'disabled');
desLogic.change_editor_tab(targetTab);
setTimeout(function () {
$('.slot_text textarea').removeAttr('disabled');
}, 50);
});
//TEXT SLIDER:
var sliderTooltip = function (event, ui) {
var curValue = (typeof ui.handle !== 'undefined') ? desLogic.scaleSliderToFontSize(ui.value) : 100;
var tooltip = '
' + curValue + 'px
';
$('#slider_fontsize .ui-slider-handle').html(tooltip);
};
$("#slider_fontsize").slider(
{
//DZ 21may17 (18may17 too): new fontsize slider
//value: 20,
//min: 13,
//max: 200,
//step: 1,
value: 10,
min: 0,
max: 98,
step: 1,
create: function (event, ui) {
sliderTooltip(event, ui);
},
slide: function (event, ui) {
sliderTooltip(event, ui);
updateTextSize(ui);
//DZ 11mar18: SAM merge, didnt exist on SAM:
/* DZ 27feb18: ME-149 */
if (inMobileMode)
$('#slider_fontsize .slider-tooltip').show();
},
change: function (event, ui) {
sliderTooltip(event, ui);
updateTextSize(ui);
},
stop: function (event, ui) {
if (!inMobileMode && desLogic.text_design_popup_current_target.parent().hasClass('freesize'))
uxController.fix_popup_pos_near_element($('#popup_text_style'), desLogic.text_design_popup_current_target.parent());
desLogic.mark_as_dirty();
//DZ 11mar18: SAM merge, didnt exist on SAM:
/* DZ 27feb18: ME-149 */
if (inMobileMode)
$('#slider_fontsize .slider-tooltip').hide();
}
});
//DZ 3jan17:
//function updateTextSize(ui) {
var updateTextSize = function (ui) {
var freesize_mode = desLogic.text_design_popup_current_target.parent().hasClass('freesize');
var oldWidth = freesize_mode ? desLogic.text_design_popup_current_target.width() : 0;
//DZ 21may17 (18may17 too): new fontsize slider
var newFontSize = desLogic.scaleSliderToFontSize(ui.value); //ui.value
desLogic.text_design_popup_current_target.css({
'font-size': newFontSize + 'px',
'line-height': lineHeightMultiplier(parseFloat(newFontSize), getFontName(desLogic.text_design_popup_current_target.css('font-family'))) + 'px'
});
var newWidth = freesize_mode ? desLogic.text_design_popup_current_target.width() : 0;
desLogic.reinit_autosizer(desLogic.text_design_popup_current_target, true);
//here we fix the 'left' position according to text-alignment (similiar to
if (!desLogic.text_design_popup_current_target.parent().hasClass('freesize')) {
var new_font_size = desLogic.auto_change_textarea_font_size(desLogic.text_design_popup_current_target);
return new_font_size == newFontSize;
}
}
$(".font_size_controller").click(function () {
var direction = $(this).attr('id') == "font_smaller" ? -1 : 1;
var selection = $("#slider_fontsize").slider("value");
$("#slider_fontsize").slider("value", selection + (direction * 1));
//DZ 24sep17: was missing!
desLogic.mark_as_dirty();
});
bind_stickers();
//COLORS
thisController.init_color_palette();
//CLICK ON SLOT PHOTO:
var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchend' : 'click';
$('body').on(eventName, '.slot_photo', function (ev) {
var isRotateButton = is_admin_mode && ev.target != null && $(ev.target).hasClass('rotate_handle');
//DZ 26jan16: adding another hotfix, for delete button:
var isDeleteButton = ev.target != null && $(ev.target).hasClass('delete');
if (!isDrag() && !isRotateButton && !isDeleteButton && !(inMobileMode && window.now_scrolling)) {
debug.log('.slot_photo.click()');
//if already in focus, shw the design popup:
desLogic.context_slot_photo = $(this);
//if slot is already in focus, have photo, and popup not already open - open the upload dialog
if (!inMobileMode && desLogic.context_slot_photo.hasClass('now_in_focus') && $('#popup_image_style:visible').length == 0 && $(this).find('img').length > 0) {
//DZ 9jul14: ehud asked to disable this behavior
//thisController.image_design_popup_open(desLogic.context_slot_photo);
}
else {
desLogic.set_focus(desLogic.context_slot_photo);
var slot_has_photo = $(this).find('img').length == 0;
//if no image - show upload option, if not - show popup / drawer
if (inMobileMode) {
//mobile - allow upload, or show drawer
if (slot_has_photo) {
uxController.close_all_drawers();
//DZ 2aug17: upload image used to be modal, now drawer
//$('#upload-photo-modal').modal('show');
//DZ 19mar18: adding wrapper for ionic get permissions (android scenario)
//uxController.open_drawer('#upload-photo-drawer');
if (editorAppMode !== "SAM")
uxController.open_drawer('#upload-photo-drawer');
else {
console.log('Editor.Sharded - SAM hotfix - using ionic wrapper for permissions');
ionicRequestFilePermissions(function () {
uxController.open_drawer('#upload-photo-drawer');
});
}
}
else {
//DZ 5apr17: this doesnt work
uxController.openPhotoDrawer(desLogic.context_slot_photo); //show-drawer:
}
}
else {
//desktop - allowupload if no image. popup is opened with another click on .edit icon
if (slot_has_photo) {
uxController.close_all_popups();
uxController.show_popup_centered($('#popup_upload_photo'));
}
}
}
}
});
//ONE CLICK UPLOAD from label element
//EXPLANATION:
//- normal upload picture from compter scenario (html5 fileAPI supported): clicking #btn_upload_from_computer image/label with 'for' attribute, invoking fileupload_image
//- old support (no fileAPI support): #btn_upload_from_computer image/label has its 'for' attribute removed, and is assigned with uploadify event
//@*DZ 16mar17: removing this one - no longer supporting IE9 or SafariPC*@
function getOrientation(file, callback) {
var reader = new FileReader();
reader.onload = function (e) {
var view = new DataView(e.target.result);
if (view.getUint16(0, false) != 0xFFD8) return callback(-2);
var length = view.byteLength, offset = 2;
while (offset < length) {
var marker = view.getUint16(offset, false);
offset += 2;
if (marker == 0xFFE1) {
if (view.getUint32(offset += 2, false) != 0x45786966) return callback(-1);
var little = view.getUint16(offset += 6, false) == 0x4949;
offset += view.getUint32(offset + 4, little);
var tags = view.getUint16(offset, little);
offset += 2;
for (var i = 0; i < tags; i++)
if (view.getUint16(offset + (i * 12), little) == 0x0112)
return callback(view.getUint16(offset + (i * 12) + 8, little));
}
else if ((marker & 0xFF00) != 0xFF00) break;
else offset += view.getUint16(offset, false);
}
return callback(-1);
};
reader.readAsArrayBuffer(file);
}
//$('#alternate_upload_image').hide();
$(document).on('change', '#fileupload_image', function (e) {
now_loading_start();
console.log('fileupload onChange');
//YZ 19-AUG-18: skipping check if no files found (causes crash in IE11)
if (e.target.files.length > 0) {
var filename = e.target.files[0].name ? e.target.files[0].name.toLowerCase() : '';
if (!desLogic.isValidFileName(filename)) {
uxController.bind_simple_popup("popup_with_close_btn", "Invalid file uploaded", "Please upload a JPEG, PNG or GIF file", getLocCaption("Close"));
uxController.show_popup_centered($('#popup_simple_template'));
now_loading_stop();
return;
}
}
//DZ 7may17: this fixes orientation for uploaded photos (ME-23)
//desLogic.add_image_to_context_slot_image(event.target.result, function () {
//https://github.com/blueimp/JavaScript-Load-Image#usage
loadImage(e.target.files[0], function (img, metadata) {
//console.log("got it",metadata);
desLogic.add_image_to_context_slot_image(imgToBase64(img), function () {
//bug fix for upload box: after first upload, upload html element needs to be recreated
$('#fileupload_image').val('');
var clone = $('#fileupload_image').clone();
$('#fileupload_image').remove();
if (inMobileMode) {
//close all modals:
$('.modal').modal('hide');
//DZ 2aug17: upload image used to be modal, now drawer
//$('#upload-photo-modal .modal-primary').append(clone);
$('#upload-photo-drawer .drawer-content').append(clone);
uxController.openPhotoDrawer(desLogic.context_slot_photo); //show-drawer:
}
else {
uxController.close_all_popups();
$('#popup_upload_photo .modal-primary').append(clone);
}
//DZ 28jul14: clearing input, so if same file is uploaded again event will be raised
now_loading_stop();
});
},
{
//options for loadImage
orientation: true //should fix orientation
});
});
//delete photo from icon
$('body').on('click', '.slot_photo .delete', function (ev) {
desLogic.context_slot_photo = $(this).parents('.slot_photo');
if (desLogic.context_slot_photo.hasClass('has_photo')) {
desLogic.context_slot_photo.find('.photo_holder img').remove();
desLogic.context_slot_photo.removeClass('has_photo');
desLogic.context_slot_photo.removeAttr('unfiltered_src');
desLogic.context_slot_photo.removeAttr('filter_name');
desLogic.context_slot_photo.removeAttr('current_frame');
//delete borders:
desLogic.context_slot_photo.find('.slot_frame_corner,.slot_frame_shape_layer,.slot_frame_line').remove();
}
else {
//DZ 28oct14:
//no image, for admin mode we remove the entire slot
if (is_admin_mode)
desLogic.context_slot_photo.remove();
}
//ev.preventDefault();
desLogic.close_popups_or_drawers();
ev.stopPropagation();
});
//delete textslot handle:
//DZ 11mar18: SAM code merge - didnt exist on SAM
//DZ 19dec17: this fixes ME-145. i've checked some other places where same error could raise - it doesnt. so far "fixing" only this part.
//$('body').on('click', '.slot_text .delete_handle', function () {
$('body').on(eventName, '.slot_text .delete_handle', function () {
$(this).parents('.slot_text').remove();
desLogic.close_popups_or_drawers();
});
//SAVE
//DZ 20jan15: save popup:
//DZ 4apr17: no idea why '#btn_open_save_dialog_finish' is here.
//DZ 6dec17: applied similiar logic in SAM logic
//$('.btn_open_save_dialog, #btn_open_save_dialog_finish').click(function () {
$('.btn_open_save_dialog').click(function () {
desLogic.close_popups_or_drawers();
$.publish('designer.save.click'); //invi
//DZ 26mar15: adding authentication
authenticate().done(function (d) {
var authd = d;
authd.withoutrefresh = true;
afterauth.resolve(authd);
/*YZ 9/7/18 - task CIE-27 new save draft mechanism on editor*/
if (desLogic.context_save_name != null) {
//if user already saved/loaded card, so we know the savename so we save
$('#user_save_name').val(desLogic.context_save_name);
$(".save_label.saving").fadeIn(250).css('display', 'inline-block');
$(".btn_open_save_dialog").toggle();
saveUserCard(function () {
desLogic.mark_as_clean();
$(".save_label.saving").toggle();
$(".save_label.saved").fadeIn(250).css('display', 'inline-block');
setTimeout(function () {
$(".save_label.saved").toggle();
$(".btn_open_save_dialog").fadeIn(250);
}, 2500);
if (editorMode == 'invitations') {
//save current cardcode as draft
draftCardCode = draftCardCode || userCardCode;
}
},
function (ex) {
$(".save_label").hide();
$(".btn_open_save_dialog").toggle();
ajax_show_error_popup_handler(null, null, null, '');
});
}
else {
//show the savename entry popup:
$('#user_save_name').val(cardConfig.title);
desLogic.close_popups_or_drawers();
if (inMobileMode)
uxController.open_drawer('#save-draft-for-later-drawer');
else
uxController.show_popup_centered($('#popup_save'));
$('#user_save_name').focus();
}
});
});
//NOT USED IN SAM:
$('#btn_save').click(function () {
var saveName = $('#user_save_name').val().trim();
if (saveName.length === 0) {
alert("Please enter a save name.");
$('#user_save_name').focus();
}
else {
$.publish('designer.save.start'); //invi
now_loading_start();
saveUserCard(function () {
//SUCCESS FUNCTION: show OK message
desLogic.close_popups_or_drawers();
now_loading_stop();
//DZ 16jun15: adding localization in JS
if (inMobileMode) {
uxController.bind_simple_drawer("popup_with_close_btn", getLocCaption("Save"), getLocCaption("html_save_complete"), getLocCaption("Done"));
}
else {
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("Save"), getLocCaption("html_save_complete"), getLocCaption("Done"));
uxController.show_popup_centered($('#popup_simple_template'));
}
desLogic.mark_as_clean();
desLogic.context_save_name = $('#user_save_name').val();
//DZ 19jul15:
$.publish('designer.save.done', [editorMode, getSavedJsonStringForStats()]);
if (editorMode == 'invitations') {
//save current cardcode as draft
draftCardCode = draftCardCode || userCardCode;
}
}, function (ex) {
debug.error('failed saving card', ex);
desLogic.close_popups_or_drawers();
//FAIL FUNCTION:
now_loading_stop();
var message = '';
if (ex !== undefined && ex.responseText) {
try {
message = JSON.parse(ex.responseText).message;
window.onerror("Error saving card:" + message);
} catch (pex) { }
}
ajax_show_error_popup_handler(null, null, null, '');
});
}
});
//making 'enter' work on save dialog:
var savePopupContainerSelector = inMobileMode ? '#save-draft-for-later-drawer' : '#popup_save';
$(savePopupContainerSelector).keypress(function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
$('#btn_save').click();
return false;
}
})
setInviteLayoutDimensions();
//FACEBOOK PHOTO POPUPS
$('#btn_upload_from_facebook').click(function (ev) {
//DZ 11mar18: SAM code merge
//DZ 20dec17:
if (editorAppMode !== "SAM")
{
FB.login(function (response) {
if (response.authResponse) {
debug.log('FBLOGIN: user logged in');
fb_user_axx_token = response.authResponse.accessToken;
desLogic.close_popups_or_drawers();
//thisController.close_all_popups();
desLogic.show_fb_albums_popups('albums');
} else {
debug.log('FBLOGIN: User cancelled login or did not fully authorize.');
}
}, {
scope: 'user_photos'
});
}
else
{
//DZ 20dec17: SAM mode - connecting to FB from ionic scope:
parent.openFBGallery();
}
});
//back button
$('body').on(eventName, '#popup_facebook_photo_upload .back', function (ev) {
desLogic.close_popups_or_drawers();
desLogic.show_fb_albums_popups('albums');
});
//fb logout button:
$('body').on(eventName, '#popup_facebook_photo_upload .log-out', function (ev) {
debug.log('fb logout');
desLogic.close_popups_or_drawers();
FB.logout(function () {
debug.log('fb logout - done');
});
});
//click on FB popup ALBUM item
$('body').on('click', '#popup_facebook_photo_upload.mode_albums .img-content .img', function (ev) {
var jqElm = $(this);
var albumId = jqElm.attr('album_id');
desLogic.close_popups_or_drawers();
desLogic.show_fb_albums_popups('photos', albumId);
});
//click on FB popup PHOTO item
$('body').on('click', '#popup_facebook_photo_upload.mode_photos .img-content .img', function (ev) {
var jqElm = $(this);
var image_url = jqElm.attr('image_url');
now_loading_start();
//YZ 6/1/18 - now all photos from FB are neing transformed into base64 instead of having direct link, this solves issues in online invitations &
//have single behaviour where ALL images are being transformed into base64
var proxied_image_url = "..\\MS_59.html?url=" + encodeURIComponent(image_url);
imgUrlToBase64(proxied_image_url, function (b64img) {
desLogic.add_image_to_context_slot_image(b64img, function () {
desLogic.close_popups_or_drawers();
now_loading_stop();
});
});
////proxying and wrapping with CORS to enbable un-tainted canvs
//var proxied_image_url = "..\\MS_59.html?url=" + encodeURIComponent(image_url);
////DZ 6aug15: added safari treatment, used to throw error on unexplained CORS issues after applying filter to FB imported image
//var isSafari = sayswho().indexOf('Safari') > -1;
//if (isSafari ) {
// imgUrlToBase64(proxied_image_url, function (b64img) {
// desLogic.add_image_to_context_slot_image(b64img, function () {
// desLogic.close_popups_or_drawers();
// now_loading_stop();
// });
// });
//}
//else {
// desLogic.add_image_to_context_slot_image(proxied_image_url, function () {
// desLogic.close_popups_or_drawers();
// now_loading_stop();
// });
//}
});
//DZ 21jan18: no more pixter, commented:
//pro print
//$(".btn_invitation_order").click(function () {
// desLogic.initProPrint();
//});
//$('#popup_text_in_margins #link_text_proceed_anyway').click(function () {
// desLogic.close_popups_or_drawers();
// printOrder();
// $.publish('designer.pro_print');
//});
//YZ 5/9/18 - skip for admin since not required and causes JS errors
if (!is_admin_mode) {
bind_finish_btn();
}
//DZ 17aug17: forcing select2 to run on this page (initally for cards finish)
if ($().select2) {
$(".custom-select").select2({
minimumResultsForSearch: Infinity
});
}
//YZ 10Apr18: RSVP cards are for print only - hiding sending online
if (typeof isRSVP !== "undefined" && isRSVP) {
$("#finish-option-send-online").addClass('_invisible');
}
//YZ 15/7/18 - for editing already saved online invitation, save draft is hidden
if (!is_admin_mode && typeof (onlineInvitation.saved) !== "undefined" && onlineInvitation.saved) {
$(".btn_open_save_dialog").css('visibility', 'hidden');
}
//DZ 17jul18: custom stickers: using trick from 'fileupload_image'
//DZ 5sep18: merged into SAM, but still not supported on SAM, only on desktop
if (editorAppMode !== 'SAM') {
$(document).on('change', '#fileupload_sticker', function (e) {
now_loading_start();
debug.log('sticker fileupload onChange');
//DZ 29jul18: CIE-285 - Uploading non image file instead of image (in image slot) or custom sticker causes a crash
//YZ 19-AUG-18: skipping check if no files found (causes crash in IE11)
if (e.target.files.length > 0) {
var filename = e.target.files[0].name ? e.target.files[0].name.toLowerCase() : '';
if (!desLogic.isValidFileName(filename)) {
uxController.bind_simple_popup("popup_with_close_btn", "Invalid file uploaded", "Please upload a JPEG, PNG or GIF file", getLocCaption("Close"));
uxController.show_popup_centered($('#popup_simple_template'));
now_loading_stop();
return;
}
}
//DZ 7may17: this fixes orientation for uploaded photos (ME-23)
//desLogic.add_image_to_context_slot_image(event.target.result, function () {
//https://github.com/blueimp/JavaScript-Load-Image#usage
loadImage(e.target.files[0], function (img, metadata) {
//DZ 29jul18: CIE-287 - Custom Sticker - always converted to PNG
var filenameExtensionIsPng = filename.toLowerCase().indexOf('.png\\.png') >= 1;
//base64:
var stickerSrc = (filenameExtensionIsPng) ? imgToBase64_png(img) : imgToBase64(img);
var jqFrame = $('.editorTab.active .editorFrame:first');
var stickerContainer = thisController.place_sticker_on_designer(stickerSrc, jqFrame, 20 + 'px', 20 + 'px');
//var hei = this.height;
//if (!hei || hei === '0px') {
// console.log('AUTO FIXING HEIGHT FOR STICKER', this);
// hei = 'auto';
//}
//stickerContainer.css({
// left: this.left,
// top: this.top,
// height: hei, //this.height,
// width: this.width,
// 'z-index': this.zIndex,
// visibility: 'visible'
//});
$('#fileupload_sticker').val('');
var clone = $('#fileupload_sticker').clone();
$('#fileupload_sticker').remove();
$('#add-custom-sticker-container').append(clone);
now_loading_stop();
},
{
orientation: true //should fix orientation
});
});
}
}; //end init_editor_shared_ux
//DZ 29jul18:
this.isValidFileName = function (filename) {
return filename && (filename.indexOf('.png\\.png') >= 1 || filename.indexOf('.jpeg') >= 1 || filename.indexOf('.jpg\\.jpg') >= 1 || filename.indexOf('.gif\\.gif') >= 1);
}
//DZ 11jul17: single point of binding (used to be in 4 different places)
//PRIVATE: binds the btn_combined_finish
function bind_finish_btn() {
//for each type, we set 2 handler: one with preview (desktop / tablet), one general (opens modal - for all)
//handlerOpener - just opens the relevant finish modal, resets and inits anything required
//handlerForPreview - inits preview images, then runs handlerOpener
var handlerOpener = null;
var handlerForPreview = null;
switch (editorMode) {
//DZ 11sep17: adding ecards_v2 support:
case "cards":
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//case "ecards_v2":
case "ecards":
//DZ 27sep17: copying this here from 'ecards' (not _v2) scenario
//reseting einvite stuff:
online_invite_public_url = null;
//DZ 11mar18: SAM code merge - didnt exist in SAM
handlerOpener = function () {
desLogic.func_update_preview_panel();
$('.finish-step').hide();
$('.finish-step.-first-step').show();
//23jul17: after changing Finish_cards layout: also hiding preview-section if not first step
$('#popup_finish_tabs_cards').removeClass('showing-full-width-instructions');
if (inMobileMode)
$('#popup_finish_tabs_cards').modal('show');
//else
//DZ 23nov17: (DC-67) ecards finish screen opened on bottom on screen and party hidden on first click
//DZ 25jan18: used to open popup always in first tab. now the tabs are removed, so for desktop we do this after invoking the click (search for this comment in code)
//setTimeout(function () {
// uxController.show_popup_centered($('#popup_finish_tabs_cards'));
//}, 500);
createSendPanel('card');
};
handlerForPreview = function () {
now_loading_start();
//clearing previous generated preview images (to clear mem)
$('.print_summary_preview img.generated_preview_page').remove();
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
var canvasW = config_render.card_print_summary_width;
var canvasH = parseInt(canvasW * heightRatio);
var selectorFirstPages = '.print_summary_preview .grid_1-2:nth-child(1) .page_sheet';
var selectorSecondPages = '.print_summary_preview .grid_1-2:nth-child(2) .page_sheet';
render_image_from_frame($('.tabBack .editorFrame'), canvasW, canvasH, function (currentImgData) {
$(selectorFirstPages).append($('
![]()
').attr('id', 'preview_img_back').addClass('generated_preview_page').attr('src', currentImgData));
render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (currentImgData) {
$(selectorFirstPages).append($('
![]()
').attr('id', 'preview_img_front').addClass('generated_preview_page').attr('src', currentImgData));
//DZ 14sep17:
$('#popup_finish_tabs_cards .preview-section .send-online-preview-section .preview-image-holder img').attr('src', currentImgData);
render_image_from_frame($('.tabInside .editorFrame:first'), canvasW, canvasH, function (currentImgData) {
$(selectorSecondPages).append($('
![]()
').attr('id', 'preview_img_inside1').addClass('generated_preview_page').attr('src', currentImgData));
render_image_from_frame($('.tabInside .editorFrame:last'), canvasW, canvasH, function (currentImgData) {
$(selectorSecondPages).append($('
![]()
').attr('id', 'preview_img_inside2').addClass('generated_preview_page').attr('src', currentImgData));
now_loading_stop();
handlerOpener();
});
});
});
});
}
break;
case "invitations":
handlerOpener = function () {
//reseting einvite stuff:
online_invite_public_url = null;
if (inMobileMode) {
$('#popup_finish_tabs').modal('show');
desLogic.autoscale_finish_preview();
}
//DZ 25jan18: used to open popup always in first tab. now the tabs are removed, so for desktop we do this after invoking the click (search for this comment in code)
//else {
// uxController.show_popup_centered($('#popup_finish_tabs'));
//}
//DZ 25jul17: premium watermark, when opening, we check for previous payment (or payment in this session in a previous opening of this popup), and set the mode of this section (paid, not paid)
set_buy_premium_watermark_section();
createSendPanel('invitation');
};
handlerForPreview = function () {
var dimensions = desLogic.getOrderRenderDimensions(renderDimensions.thumbnail);
render_image_from_frame($('.tabFront .editorFrame'), dimensions.width, dimensions.height, function (img_src) {
//$(".envelope .card").attr('src', img_src);
//setting preview images in free/premium, DIY popups:
//DZ 21jan18: removing pixter:
//$("#popup_free_or_premium .intro-image img").attr('src', img_src);
//23jul17: pay 4 watermark - creating another preview with the watermark:
//making the watermark visible (for rednerer, not in UI) for rendering a preview with watermark:
$(".decor_watermark").addClass('show-watermark-in-preview');
render_image_from_frame($('.tabFront .editorFrame'), dimensions.width, dimensions.height, function (img_src_with_watermark) {
$(".decor_watermark").removeClass('show-watermark-in-preview');
//$('#popup_finish_tabs .preview-section img').attr('src', img_src);
thisController.preview_img_src = img_src;
thisController.preview_img_src_with_watermark = img_src_with_watermark;
show_invi_previews_according_to_watermark_selection();
//DZ 7feb18: unreproducable/unresolved iPad issue CIE-265 left this timer hack not working. invoking twice just in case (adding this once below after rendering & showing invi previews)
if (thisController.func_update_invitations_preview_panel)
thisController.func_update_invitations_preview_panel();
handlerOpener();
});
});
};
break;
default:
console.error("bind_finish_btn - unknown editorMode", editorMode);
}
//DZ 22jan17: new finish button behavior:
//expose the pulldown:
//YZ 15/7/18 - for editing already saved online invitation - click NEXT goes directly to event details
$('#finish-pulldown-trigger').click(function () {
if (typeof (onlineInvitation.saved) !== "undefined" && onlineInvitation.saved) {
startSendOnlineV2Flow();
return;
}
$('#finish-button-wrapper').toggleClass('is-open');
});
//pulldown option clicked:
$('#finish-pull-down li').click(function (ev) {
//DZ 31jan18: added this (caused real issues on slow renders because of timings). removed from someplace else
desLogic.close_popups_or_drawers();
var dataTabName = $(this).attr('data-tab-name');
//DZ 16may18: new sendonline (www only, not SAM):
if (dataTabName === 'share' && editorMode === 'invitations') {
$.publish('designer.send', [editorMode]);
startSendOnlineV2Flow();
return;
}
var should_show_preview = !inMobileMode || desLogic.inMobileTabletMode();
if (should_show_preview)
handlerForPreview();
else
handlerOpener();
//old logic: used to open popup and then click
$('.tabs .tabs-nav > li').hide();
$('.tabs .tabs-nav > li[data-tab-name=' + dataTabName + ']').show();
//click will change 'tab' content:
//DZ 7feb18: used to invoke both click events for both tab sets - cards & invitations, could cause issues:
//$('.tabs .tabs-nav > li[data-tab-name=' + dataTabName + ']').click();
var modalName = editorMode == 'invitations' ? '#popup_finish_tabs' : '#popup_finish_tabs_cards';
$(modalName + ' .tabs .tabs-nav > li[data-tab-name=' + dataTabName + ']').click();
//DZ 23nov17: (DC-67) ecards finish screen opened on bottom on screen and party hidden on first click
//DZ 25jan18: used to open popup always in first tab. now the tabs are removed, so for desktop we do this after invoking the click (search for this comment in code)
//for desktop, we open the popup centered here
setTimeout(function () {
if (!inMobileMode) {
//DZ 7feb18: simplifying
uxController.show_popup_centered($(modalName));
//DZ 16may18: doing a partial fix for laptop screens (CIE-277)
//making position absolute, enabling to scroll content up/down
if (window.innerHeight < 600) {
console.log('applying laptop fix for finish. old/new margin-top:', parseInt($(modalName).css('margin-top')), (parseInt($(modalName).css('margin-top')) - 50));
$(modalName).css({
position: 'absolute',
'margin-top': (parseInt($(modalName).css('margin-top')) - 50) + 'px'
})
}
else
$(modalName).css({ position: 'fixed' });
}
//if (editorMode == 'invitations')
// uxController.show_popup_centered($('#popup_finish_tabs'));
//else
// uxController.show_popup_centered($('#popup_finish_tabs_cards'));
//this is for invitations:
if (thisController.func_update_invitations_preview_panel) {
thisController.func_update_invitations_preview_panel();
}
}, 500);
$('#finish-button-wrapper').removeClass('is-open');
});
//real final function that handles the button:
//DZ 23jan18: removed. new finish in town
//$('#btn_combined_finish').click(function () {
// //DZ 21jan17: removed.
// //YZ 06Mar 16: skipping directly to pixter dialog if orderPrinted is true
// //if (editorMode == 'invitations' && typeof orderPrinted !== "undefined" && orderPrinted === 'True') {
// // thisController.initProPrint();
// //}
// //else {
// // //now we've set our handlers, we actually handle:
// var should_show_preview = !inMobileMode || desLogic.inMobileTabletMode();
// if (should_show_preview)
// handlerForPreview();
// else
// handlerOpener();
// //}
//});
}
function createSendPanel(type) {
if (inMobileMode) {
if (!OnlineSender) {
OnlineSender = new SendOnlineMobileModule(type, desLogic);
}
OnlineSender.createSendPanel();
}
else {
if (!OnlineSender) {
OnlineSender = new SendOnlineDesktopModule(type, desLogic);
}
OnlineSender.createSendPanel();
}
}
//private: this binds the section to display 'already purchased' if needed
function set_buy_premium_watermark_section() {
if (premium_watermark_removal_was_paid || premium_remove_watermark.initial_state == 'PAID') {
$('#popup_finish_tabs').addClass('premium_watermark_removal_paid');
$('#popup_finish_tabs .onoffswitch input').prop('checked', true).attr('disabled', 'disabled');
//post purchase texts:
$('#popup_finish_tabs #btn_download_from_tabs_popup .btn-text').text(' Download');
$('#popup_finish_tabs #btn_invitations_print_from_popup .btn-text').text(' Print');
$('#popup_finish_tabs .watermark-tooltip').text('?'); //✓
$('#popup_finish_tabs .watermark-text').text('watermark-free version');
//hacking the qTip tooltip to stop working:
//$('.premium_remove_watermark .wm-desc .watermark-tooltip').css('pointer-events', 'none');
}
}
//private:
function show_invi_previews_according_to_watermark_selection() {
var img_src = $('#premium_no_watermark_onoff').is(':checked') ? thisController.preview_img_src : thisController.preview_img_src_with_watermark;
$('#popup_finish_tabs .preview-section img:not(.icon-play-gradient-ph)').attr('src', img_src);
}
this.inMobileTabletMode = function () {
return $('html').hasClass('tablet');
}
//private: close drawers or popups (mobile or desktop)
this.close_popups_or_drawers = function () {
if (inMobileMode) {
$('.modal').modal('hide'); //DZ 12apr17: added this line, for closing "finish" modal when download image/pdf
uxController.close_all_drawers();
}
else
uxController.close_all_popups();
}
//public - used for two purposes: show the FB albums (from upload popup) or show a specific FB album (from inside the albums poopup)
this.show_fb_albums_popups = function (mode, albumId) {
//bind popup images:
var firstTime = true;
var fillFunc = function (fbResp) {
//bind popup text fields:
//$('#popup_facebook_photo_upload .back').toggle(mode == 'photos');
if (mode == 'photos')
$('#popup_facebook_photo_upload .back').css('visibility', "visible");
else
$('#popup_facebook_photo_upload .back').css('visibility', "hidden");
$('#dynamic_fb_title').text(mode == 'photos' ? "Photos" : "Albums");
//css class mode_albums OR mode_photos
$('#popup_facebook_photo_upload').removeClass('mode_photos').removeClass('mode_albums').addClass('mode_' + mode);
if (inMobileMode)
$('#popup_facebook_photo_upload').modal('show');
else
uxController.show_popup_centered($('#popup_facebook_photo_upload'));
debug.log('filling fb popup with ' + fbResp.data.length + ' items', fbResp);
var gridClass = inMobileMode ? "grid_1-3" : "grid_1-6";
$('#popup_facebook_photo_upload .img-content .img').remove();
if (firstTime && mode == 'albums') {
//YZ 26-JUL-16:
//Creating 'Photos of me' album with thumb image of 1st image returned
debug.log('adding tagged images');
FB.api('/v3.2/me/photos/tagged', function (res) {
if (res.data.length > 0) {
console.log('found tagged images');
//newDiv = $('
')
newDiv = $('
')
.attr({ title: 'Photos of me', album_id: 'tagged' })
.append($('
')
.append($('
![]()
').attr({ alt: 'Photos of me', src: '..\\https\\graph.facebook.com\\MS_7767.html' + res.data[0].id + '..\\MS_7800.html?access_token=' + fb_user_axx_token })))
//$('#popup_facebook_photo_upload .img-content .clear').after(newDiv);
$('#popup_facebook_photo_upload .img-content').prepend(newDiv);
}
});
}
firstTime = false;
var nextPage;
function populate(fbResp) {
var idx = 0;
$(fbResp.data).each(function () {
var newDiv;
if (mode == "albums")
newDiv = $('
')
.attr({
title: this.name,
album_id: this.id
})
.append($('
')
.append($('
![]()
').attr({
alt: this.name,
src: '..\\https\\graph.facebook.com\\MS_7767.html' + this.id + '..\\MS_7800.html?access_token=' + fb_user_axx_token
})))
else //mode == 'photos'
newDiv = $('
')
.attr({
title: this.name,
image_id: this.id,
image_url: this.images[0].source
})
.append($('
')
.append($('
![]()
').attr({
alt: this.name,
src: this.picture
})));
//if (idx <= 5)
// newDiv.addClass('_no-mg-t');
//newDiv.find('img').addClass('_no-mg-t');
$('#popup_facebook_photo_upload .img-content').append(newDiv);
idx++;
});
//getting the url of next page of photos
nextPage = fbResp.paging.next;
}
populate(fbResp);
//YZ 26-JUL-16: Implementing endless scroll with FB pagination system since FB returns only 25 items each call
//$('#popup_facebook_photo_upload .img-content').on('scroll', function () {
$('#popup_facebook_photo_upload .photos-upload-container').on('scroll', function () {
debug.log('checking scroll', $(this).scrollTop(), $(this).innerHeight(), $(this)[0].scrollHeight, nextPage)
if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight && nextPage !== undefined) {
//console.log('getting next fb photos/albums');
FB.api(nextPage, populate);
}
})
};
desLogic.close_popups_or_drawers();
//YZ 26-JUL-16:
//photos i'm tagged in
if (mode == 'photos' && albumId === 'tagged') {
FB.api('/v3.2/me/photos/tagged', { fields: ['id', 'name', 'images', 'picture'] }, fillFunc);
}
else if (mode == 'photos')
FB.api('/v3.2/' + albumId + '..\\photos.html', { fields: ['id', 'name', 'images', 'picture'] }, fillFunc);
else {
FB.api('/v3.2/me/albums/', fillFunc);
//DZ 9jan17: moved code that ran here. was race condition
}
};
//private: shared by both Mobile drawer & desktop popup for editing images
//function init_image_design_popup () {
function init_image_design_options() {
debug.log('init_image_design_options');
//zoom slider
var sliderTooltip = function (event, ui) {
var curValue = (typeof ui.handle !== 'undefined') ? ui.value * 100 : 100;
curValue = Math.floor(curValue);
var tooltip = '
' + curValue + '%
';
$('#slider_image_zoom .ui-slider-handle').html(tooltip);
};
$("#slider_image_zoom").slider(
{
value: 1,
min: 1,
max: 10,
step: 0.05,
create: function (event, ui) {
sliderTooltip(event, ui);
},
slide: function (event, ui) {
//desLogic.context_slot_photo.attr('current_zoom', ui.value);
sliderTooltip(event, ui);
//silent to ensure panzoomzoom event wont be called
desLogic.context_slot_photo.find('.photo_holder img').panzoom('zoom', ui.value, { silent: true });
var $zoom = $("#zoom-too-much");
if (ui.value > 4) {
$zoom.slideDown(function () {
$zoom.closest(".qtip").qtip('reposition');
});
}
else {
$zoom.slideUp(function () {
$zoom.closest(".qtip").qtip('reposition');
});
}
},
change: function (event, ui) {
//desLogic.context_slot_photo.attr('current_zoom', ui.value);
sliderTooltip(event, ui);
//silent to ensure panzoomzoom event wont be called
desLogic.context_slot_photo.find('.photo_holder img').panzoom('zoom', ui.value, { silent: true });
}
});
$(".zoom-control").click(function () {
var direction = $(this).attr('id') == "zoom_in" ? 1 : -1;
var selection = $("#slider_image_zoom").slider("value");
$("#slider_image_zoom").slider("value", selection + (direction * 0.1));
});
//ROTATING image_slot:
$('#image_edit_rotate_left,#image_edit_rotate_right').click(function () {
//now_loading_start();
desLogic.context_slot_photo.addClass('now_processing_photo_slot');
var jqElm = desLogic.context_slot_photo.find('.photo_holder img');
var degrees = parseInt($(this).attr('rotate'));
if (degrees < 0) degrees = degrees + 360;
debug.log('rotating image ' + degrees);
get_rotated_image_helper(jqElm.attr('src'), degrees, function (rotatedImageData) {
debug.log('clearing slot');
var oldMatrix = jqElm.panzoom('getMatrix');
jqElm.panzoom('destroy');
jqElm.remove();
debug.log('adding to slot. img data len=', rotatedImageData.length);
desLogic.add_image_to_context_slot_image(rotatedImageData, function () {
desLogic.context_slot_photo.find('.photo_holder img').panzoom('setMatrix', oldMatrix);
desLogic.context_slot_photo_revert_data.rotation = (desLogic.context_slot_photo_revert_data.rotation + degrees) % 360;
//making sure unfiltered_src is also rotated
if (desLogic.context_slot_photo.attr('unfiltered_src') == null) {
//now_loading_stop();
desLogic.context_slot_photo.removeClass('now_processing_photo_slot');
}
else {
debug.log('rotating unfiltered_src');
//var clone_jqImg_with_unfiltered_img = desLogic.context_slot_photo.clone().attr('src', desLogic.context_slot_photo.attr('unfiltered_src'));
get_rotated_image_helper(desLogic.context_slot_photo.attr('unfiltered_src'), degrees, function (rotated_src) { // clone_jqImg_with_unfiltered_img, degrees, function (rotated_src) {
//debug.log('rotated_src', rotated_src);
desLogic.context_slot_photo.attr('unfiltered_src', rotated_src);
//now_loading_stop();
desLogic.context_slot_photo.removeClass('now_processing_photo_slot');
});
}
});
});
});
//EFFECTS:
//private inner method:
function invokeFilter(filter_name) {
desLogic.context_slot_photo.addClass('now_processing_photo_slot');
desLogic.render_filter_on_context_slot_photo(filter_name, function () {
desLogic.context_slot_photo.removeClass('now_processing_photo_slot');
});
}
//filters by mobile/desktop:
if (inMobileMode)
$('#effects-row-container .image-effect').click(function () {
var filter_name = $(this).data('filter-name');
invokeFilter(filter_name);
$('#effects-row-container .image-effect').removeClass('active');
$(this).addClass('active');
});
else {
$('#popup_image_style .filter input:radio[name="filter"]').change(function () {
var filter_name = this.id;
invokeFilter(filter_name);
});
//FRAMES: (n/a in mobile)
$('#popup_image_style .frame input:radio[name="frames"]').change(function () {
var frame_name = this.id;
desLogic.render_frame_on_context_slot_photo(frame_name);
});
}
//admin only:
//DZ 5feb15: INIT POSITION HELEPRS
if (is_admin_mode) {
//DZ 5feb15: INIT POSITION HELEPRS
$('#admin_image_position_center_h').click(function () {
center_element_in_editor(desLogic.context_slot_photo, true);
thisController.fix_popup_pos_near_element($('#popup_image_style'), desLogic.context_slot_photo);
});
$('#admin_image_position_center_v').click(function () {
center_element_in_editor(desLogic.context_slot_photo, false);
thisController.fix_popup_pos_near_element($('#popup_image_style'), desLogic.context_slot_photo);
});
$('#admin_image_position_keycatcher').keydown(function (ev) {
handle_keydown_for_positioning_helper(desLogic.context_slot_photo, ev);
thisController.fix_popup_pos_near_element($('#popup_image_style'), desLogic.context_slot_photo);
return false;
});
};
};
//PRIVATE - load card into designer pane
//init card params from metadata
this.bind_card_metadata = function (cardId) {
//card metadata is divided to pages inside array.
//first "page" has different treatment than rest:
//===== FIRST PAGE =====
if (is_admin_mode && cardConfig.pages == null) {
debug.log('admin mode - creating new pages field');
cardConfig.pages = [{}];
}
var page_first = cardConfig.pages[0];
//first page image:
var image_url = page_first.name;
var frameContainer = $('.editorTab.tabFront .editorFrame');
//first image used for tab overlay icon:
//(3d css not supportd by safariPC)
var isIE9 = sayswho() == "MSIE 9";
//DZ 21mar17: no more IE9 && safariPC support
//DZ 11sep17: ecards_v2
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == "cards" || editorMode=="ecards_v2") { // && !isSafariPC && !isIE9) {
if (editorMode == "cards" || editorMode == "ecards") {
$('#overlay_front_card').show().append($('
![]()
').attr('src', cardConfig.thumbnail));
}
//ecard editorFrame is insid .tabInside
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards')
// frameContainer = $('.editorTab.tabInside .editorFrame:first');
//DZ 28oct14: not always has image (as in admin new card scneario):
if (image_url != null) {
var newDecor = $('
').addClass('card_decor decor_full_image').append($('
![]()
').attr('src', image_url));
frameContainer.append(newDecor);
//YZ 29/5/17 - code used by thumbnails automation script
$(".card_decor.decor_full_image img").load(function () { $("body").addClass('mainImageLoaded'); });
}
//pre-set slots dimensions & locations are according to old card UI sizes. we'll readjust them to current sizes
//CARDS:
var OLD_CARD_WIDTH = 405;
var OLD_CARD_HEIGHT = 588;
if (editorMode == 'invitations') {
//same proportions?
}
var NEW_CARD_WIDTH = $('.editorFrame:first').width();
var NEW_CARD_HEIGHT = $('.editorFrame:first').height();
frameContainer.attr('entity_id', page_first.id);
//FIRST PAGE PHOTO FIELDS:
$(page_first.containers).each(function () {
var thisContainer = this;
//fixing various values. cant be negative, cant be more than 100%;
var fixFunc = function (val) {
var ret = val;
if (val < 0) {
ret = 0;
debug.log('fixing container value from ' + val + ' to ' + ret);
}
else if (val > 100) {
ret = 100;
debug.log('fixing container value from ' + val + ' to ' + ret);
}
return ret;
};
var newXperc = fixFunc((thisContainer.x / OLD_CARD_WIDTH) * 100);
var newYperc = fixFunc((thisContainer.y / OLD_CARD_HEIGHT) * 100);
var newWidth = fixFunc((thisContainer.width / OLD_CARD_WIDTH) * 100);
var newHeight = fixFunc((thisContainer.height / OLD_CARD_HEIGHT) * 100);
//DZ 5sep18: merging into SAM. SAM currently does not support get_template_slot_photoFront;
var newPhotoSlot;
if (editorAppMode == 'SAM')
newPhotoSlot = desLogic.get_template_slot_photo().removeClass('invis').addClass('overlay_design');
else
newPhotoSlot = desLogic.get_template_slot_photoFront().removeClass('invis').addClass('overlay_design');
//DZ 5oct14: storing entity ID
newPhotoSlot.attr('entity_id', thisContainer.id);
newPhotoSlot.css({
left: newXperc + '%',
top: newYperc + '%',
width: newWidth + '%',
height: newHeight + '%'
});
if (thisContainer.rotation && thisContainer.rotation != 0) {
//transform already contains 'translateY(-50%)' for middle vert alignment
//FOR UNKNOWN REASONS, when doing this immediately panzoom stops working. however it works well after 500ms delay
//setTimeout(function () {
newPhotoSlot.css({
//'-ms-transform': 'rotate(' + thisContainer.rotation + 'deg)', /* IE 9 */
//'-webkit-transform': 'rotate(' + thisContainer.rotation + 'deg)', /* Chrome, Safari, Opera */
'transform': 'rotate(' + thisContainer.rotation + 'deg)',
'transform-origin': 'left top'
});
//}, 5000);
}
//add to editor:
//DZ 5sep18: merging into SAM. SAM currently does not support get_template_slot_photoFront, #editorFrameFront
if (editorAppMode == 'SAM')
$('.editorFrame:first').append(newPhotoSlot);
else
$('#editorFrameFront').append(newPhotoSlot);
});
//TEXT FIELDS OF FIRST PAGE:
$(page_first.fields).each(function () {
//handle text slots
var thisField = this;
if (!(thisField.isEditable === false)) //DZ 9nov14: added for support on admin side
{
debug.log('pre-set text slot: ' + thisField.text, thisField);
//=== NOTICE: ALMOST DUPLICATE CODE in $('#btn_add_text').click()
//DZ 2feb15: also almost duplicate code in load_json_to_editor
var newTextSlot = $('#template_slot_text_freesize').clone().removeAttr('id').removeClass('invis');
//DZ 5oct14: storing entity ID
newTextSlot.attr('entity_id', thisField.id);
if (!should_have_move_handle_on_freesize_text_slots)
newTextSlot.find('.move_handle').remove();
if (!should_have_trash_handle_on_freesize_text_slots)
newTextSlot.find('.delete_handle').remove();
//DZ 15DEC15: very weired bug. when querying $(e).css('left') in rare cases we get '40%' answer instead of '545px' which we depend on. so from now changing to set px values
//position in percentage
var newXperc = (thisField.x / OLD_CARD_WIDTH) * 100;
var newYperc = (thisField.y / OLD_CARD_HEIGHT) * 100;
var newX_px = newXperc / 100 * NEW_CARD_WIDTH;
var newY_px = newYperc / 100 * NEW_CARD_HEIGHT;
//newTextSlot.css({
// left: newXperc + '%',
..\\http\\ top newyperc +\\MS_7801.html '%'
//});
newTextSlot.css({
left: newX_px + 'px',
top: newY_px + 'px'
});
//debug.error('ORIGINAL X:', thisField.x, 'PERCENT X:', newXperc, "INITIAL PLACEMENT" + newTextSlot.css('left'));
//new font size:
var newFontSize = (NEW_CARD_HEIGHT / OLD_CARD_HEIGHT) * this.size;
//DZ 7dec14: rounding font size because of issue with text not fitting slot on all browsers (reported by eli)
newFontSize = precise_round(newFontSize, 1);
//debug.error('from cardConfig:', this.size, OLD_CARD_HEIGHT, NEW_CARD_HEIGHT);
var newText = fixGIText(thisField.text); // strreplace(strreplace(thisField.text, '~~', '\n'), '~', '\n');
newTextSlot.find('textarea')
//.val(thisField.text.replace('~~', '\n').replace('~', '\n'))
.val(newText)
.attr('placeholder', ' ')
.css({
'text-align': thisField.align,
'color': '#' + thisField.color,
'font-family': getFontName(thisField.font),
'font-size': newFontSize + 'px',
'line-height': lineHeightMultiplier(newFontSize, getFontName(thisField.font)) + 'px'
});
//DZ 11jan17: REDESIGN
//newTextSlot.css('outline-color', get_outline_color('#' + thisField.color));
desLogic.setColorToJQTextSlot(newTextSlot, '#' + thisField.color);
newTextSlot.find('textarea').focus(function (e) {
if (!inMobileMode)
uxController.text_design_popup_open($(e.currentTarget));
});
//add to editor:
$('.editorFrame:first').append(newTextSlot);
//fix 5px border padding on placement:
newTextSlot.css({
left: (parseFloat(newTextSlot.css('left').replace('px', '')) - 5) + 'px',
//was 11 to fix:
top: (parseFloat(newTextSlot.css('top').replace('px', '')) - 5) + 'px'
});
//debug.error('AFTER MOVING: ' + newTextSlot.css('left'));
//DZ 30jul15: moved here after addition of textslot to container, caused location calculation issues in Safari Mac
if (thisField.rotation && thisField.rotation != 0) {
newTextSlot.css({
'-ms-transform': 'rotate(' + thisField.rotation + 'deg)', /* IE 9 */
'-webkit-transform': 'rotate(' + thisField.rotation + 'deg)', /* Chrome, Safari, Opera */
'transform': 'rotate(' + thisField.rotation + 'deg)'
});
}
freesize_init(newTextSlot.find('textarea'));
//debug.error('AFTER FREESIZE: ' + newTextSlot.css('left'));
make_text_slot_draggable(newTextSlot);
//debug.error('AFTER DRAGGABLE: ' + newTextSlot.css('left'));
//fix x,y if it exceeds card place:
//DZ 4aug14: disabled 'x' edge fixing. causes troubles with freetext positions.
//var x_edge = getEdgeX(newTextSlot);
var y_edge = getEdgeY(newTextSlot);
var containerElement = newTextSlot.parents(".editorFrame");
//if (x_edge> containerElement.width())
//{
// debug.log('fixing x edge for ', newTextSlot);
// var newLeft = parseFloat(newTextSlot.css('left').replace('px', '')) - (x_edge - containerElement.width());
// newTextSlot.css('left', newLeft + 'px');
//}
if (y_edge > containerElement.height()) {
debug.log('fixing y edge for ', newTextSlot);
var newTop = parseFloat(newTextSlot.css('top').replace('px', '')) - (y_edge - containerElement.height());
newTextSlot.css('top', newTop + 'px');
}
//debug.log(newTextSlot.find('textarea'));
//console.log("!!!!!!!!! TEST ", get_rotation_degress_of_element(newTextSlot));
}
});
var firstText = null;
//for each other (non-first) page add relevant texts:
for (card_idx = 1; card_idx < cardConfig.pages.length; card_idx++) {
var this_page = cardConfig.pages[card_idx];
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//var thisEditorFrame = (editorMode == 'ecards')
// ? $('.editorFrame:last')
// : $('.editorFrame:eq(' + (parseInt(this_page.pageNum) - 1) + ')');
var thisEditorFrame = $('.editorFrame:eq(' + (parseInt(this_page.pageNum) - 1) + ')');
thisEditorFrame.attr('entity_id', this_page.id);
for (slot_idx = 0; slot_idx < this_page.fields.length; slot_idx++) {
var thisField = this_page.fields[slot_idx];
//var thisSlot = $('.editorFrame:eq(' + (parseInt(this_page.pageNum) - 1) + ') .slot_text:eq(' + slot_idx + ')');
var thisSlot = thisEditorFrame.find('.slot_text:eq(' + slot_idx + ')');
//DZ 5oct14: storing entity ID
thisSlot.attr('entity_id', thisField.id);
//var newText = strreplace(strreplace(thisField.text, '~~', '\n'), '~', '\n');
var newText = fixGIText(thisField.text);
if (firstText == null) {
//setting the text for quick print (done only once for first text encountered)
firstText = newText;
}
var newFontSize = (NEW_CARD_HEIGHT / OLD_CARD_HEIGHT) * thisField.size;
//DZ 7dec14: rounding font size because of issue with text not fitting slot on all browsers (reported by eli)
newFontSize = precise_round(newFontSize, 1);
debug.log('slot text', newText, thisSlot);
thisSlot.find('textarea')
//.val(thisField.text.replace('~~', '\n').replace('~', '\n'))
.val(newText)
.css({
'text-align': thisField.align,
'color': '#' + thisField.color,
'font-family': getFontName(thisField.font),
'font-size': newFontSize + 'px',
'line-height': lineHeightMultiplier(newFontSize, getFontName(thisField.font)) + 'px'
});
thisSlot.css('outline-color', get_outline_color('#' + thisField.color));
thisController.reinit_autosizer(thisSlot.find('textarea'));
}
}
if (firstText == null)
$('.quick_print_text').text("No text found to put here!");
else
$('.quick_print_text').text(newText);
//DZ 1jan15: adding watermarks for invitations and ecards:
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards') {
// var targetEditorFrame = $('.editorFrame:last');
// var watermarkPngUrl = "..\\Editor\\images\\watermark_ecard.png";
// targetEditorFrame.append("

");
//} else
if (editorMode == 'invitations') {
//DZ 11mar18: SAM code merge
//DZ 31dec17 (SAM) - changed for SAM (many editorFrames included:
// var targetEditorFrame = $('.editorFrame:last');
//var watermarkPngUrl = "..\\Editor\\images\\watermark_invi.png";
var targetEditorFrame = (editorAppMode === "SAM") ? $('.editorFrame:visible:last') : $('.editorFrame:last');
var imagesUrlPrefix = 'images\\index.html';
if (editorAppMode !== "SAM")
imagesUrlPrefix = '..\\Editor\\images\\index.html';
var watermarkPngUrl = imagesUrlPrefix + "watermark_invi.png";
targetEditorFrame.append("

");
}
};
//PRIVATE
//YZ 1Jun16: moving the color palette init to seperate function to allow updading in admin
//public: bind colors, bindcolors, bindpallete
this.init_color_palette = function () {
//DZ 11may17: on admin this can happen many times, so we clear it each time
if (is_admin_mode) {
$('#popup_text_style .colors .text-color').remove();
$('#more_colors').remove();
}
var color_palette = [
'FFB400', 'E53D39', '2C91DE', '000000', 'FFFFFF',
'970E65', '650633', 'F3A2A3', 'D44F70', 'CA0B15', '97070E',
'650508', 'F35D19', '9E5727', 'D8B571', '978454', '65320C',
'8793D6', '866AA5', '552978', '1D549F', '073464', '55B2AE',
http\\MS_24.html'686868', 'D5D5D5', 'FFFAA3', 'C0CFAF', '7AAB3A', '469E57'
..\\http\\dz 25apr17 somehow we got one extra color. removing one the colors\\MS_7802.html
'686868', 'D5D5D5', 'FFFAA3', 'C0CFAF', '469E57'
];
//YZ 14Feb 16: adding option to load specific colors for each card
if (typeof precolors !== "undefined" && precolors !== null && precolors.length > 0) {
$.each(precolors, function (index, value) {
var position = $.inArray(value.toUpperCase(), color_palette);
if (position > -1) {
color_palette.splice(position, 1);
}
});
color_palette = precolors.concat(color_palette);
}
//var append_colors_here = $('#popup_text_style .colors');
var append_colors_here = inMobileMode ? $('.fonts-colors.-visible-colors') : $('#popup_text_style .colors');
//DZ 3jan17:
//$(append_colors_here).empty();
var counter = 0;
$(color_palette).each(function () {
var elmId = 'cr_' + counter;
if (counter == 5) {
var more_btn = inMobileMode ? $('#icon-more-colors') : $('#more_colors_btn');
var last_item = inMobileMode ? $('.fonts-colors.-visible-colors > span:last') : $('.colors label:last');
more_btn.insertAfter(last_item);
if (inMobileMode)
append_colors_here = $('.fonts-colors.-more-colors');
else {
//hotfixing for admin (done twice):
if (!window.bound_more_btn) {
more_btn.click(function () {
var height = $('#more_colors').height();
var nowVis = ($('#more_colors:visible').length > 0);
var newTop = (nowVis ? 1 : -1) * (height / 2) + parseInt($('#popup_text_style').css('top').replace('px'));
$('#more_colors').slideToggle(250);
$('#popup_text_style').animate({ top: newTop }, 250);
});
window.bound_more_btn = true;
}
var more_colors_container = $('
');
$('#popup_text_style .colors').append(more_colors_container);
append_colors_here = more_colors_container;
}
//append_colors_here.append(more_btn);
counter++;
}
//put the color:
if (!inMobileMode) {
var extraClasses = '';
if (this.toUpperCase() == 'FFFFFF')
extraClasses = 'whiter_adio_fix';
append_colors_here
.append('
')
.append('');
}
else {
//slightly different HTML/CSS in mobile
var extraClasses = '';
if (this.toUpperCase() == 'FFFFFF')
extraClasses = 'white';
append_colors_here
.append('
' +
'' +
'')
}
counter++;
});
}
//PRIVATE - when initing - adds user editable slots to the various frames
function add_slots_to_editors() {
var slot_photo = thisController.get_template_slot_photo();
var slot_text = thisController.get_template_slot_text();
//adding slots to inside pages:
//we add several instances of each slot, to enable switching between layouts without losing content.
//only relevant slots will be visible (all invisible on template)
var insideLeftFrame = $('.tabInside .editorFrame:first');
var insideRightFrame = $('.tabInside .editorFrame:last');
//3 photo slots:
insideLeftFrame.append(slot_photo.clone()).append(slot_photo.clone()).append(slot_photo.clone());
//3 text slots:
insideLeftFrame.append(slot_text.clone()).append(slot_text.clone()).append(slot_text.clone());
//same for right:
insideRightFrame.append(slot_photo.clone()).append(slot_photo.clone());
insideRightFrame.append(slot_text.clone()).append(slot_text.clone()).append(slot_text.clone());
//back:
var current_layout = getLayout();
var textTop;
var textHeight;
var imgslotWidth;
var imgslotHeight;
var imgslotTop;
var imgslotLeft;
switch (current_layout) {
case "landscape":
$('.tabBack .editorFrame')
.append(slot_text.clone().removeClass('invis').css({ top: '49%', height: '18%' }))
.append(slot_photo.clone().removeClass('invis').css({ top: '15%', height: '33%', width: '26%', left: '37%' }));
break;
case "square":
$('.tabBack .editorFrame')
.append(slot_text.clone().removeClass('invis').css({ top: '46%', height: '15%' }))
.append(slot_photo.clone().removeClass('invis').css({ top: '13%', height: '33%', width: '36%', left: '32%' }));
break;
default:
$('.tabBack .editorFrame')
.append(slot_text.clone().removeClass('invis').css({ top: '32%', height: '13%' }))
.append(slot_photo.clone().removeClass('invis').css({ top: '10%', height: '22%', width: '36%', left: '32%' }));
break;
}
}
//PRIVATE
function make_text_slot_draggable(newTextSlot) {
//making it draggable:
//DZ 27mar17: redmob issues with draggable. done this:
//1. updated vesrion for jquryUI (from 1.10.2 to 1.12.1)
//2. added scaling fixes, to serve mobile version
//3. disabled "revert" - now done in "drag" event. reason: scaling fixes fucked it up
newTextSlot.draggable({
addClasses: false, //this should improve performance (?)
cursor: "move",
opacity: 0.35,
//revert: "invalid",
revertDuration: 250,
handle: should_have_move_handle_on_freesize_text_slots ? '.move_handle' : false,
start: function (event, ui) {
//DZ 27mar17: for fixing dragging in scaled divs (see http://stackoverflow.com/questions/13882070/jquery-draggable-and-webkit-transform-scale)
var draggedElement = $(ui.helper.context);
//DZ 15may17: setting focus to textslot, to avoid ME-38 On some androids, selecting texts does not activate the text modification menu
//DZ 16may17: removing this - setting focus both on dragend, and touchend
//desLogic.set_focus(draggedElement);
lastDragStartPos.x = event.clientX;
lastDragStartPos.y = event.clientY;
//console.log('dragStart', event.clientX, event.clientY, ui.position.left, ui.position.top);
//DZ 21oct14: this closes the iPad keyboard when dragging:
//DZ 9may17: not relevant anymore
//if (browser_category == "tablet")
// newTextSlot.find('textarea').blur();
//makes sure dragged element has max zIndex
//thisController.bring_sticker_to_front($(this));
//showing overflow visibility: so it will be shown dragged across frames (reverted on dropped event)
$(this).parents('.editorFrameContainer').css({ overflow: 'visible' });
$(this).parents('.editorFrame').css({ overflow: 'visible' });
//DZ 17aug14: hiding popup while dragging
$('#edit-area').addClass('now_freesize_dragging');
},
stop: function () {
thisController.mark_as_dirty();
//DZ 17aug14: hiding popup while dragging
$('#edit-area').removeClass('now_freesize_dragging');
//hiding overflow visibility: so middle across frames positioned stickers will be trimmed (reverted from dragged event)
//$('.editorFrame').css({ overflow: 'hidden' });
$(this).parents('.editorFrameContainer').css({ overflow: 'hidden' });
$(this).parents('.editorFrame').css({ overflow: 'hidden' });
//fix popup position (if now open):
if (!inMobileMode && $('#popup_text_style:visible').length > 0) {
uxController.fix_popup_pos_near_element($('#popup_text_style'), desLogic.text_design_popup_current_target.parent());
}
//clear previous snapping lines:
$('.editorFrame .snapper_line').remove();
//DZ 16may17: (see other comment in bind_clickable_decors() - android sometimes 'skips' touchend event after finishing dragging, also ME-38
//console.log('checking in draggable', $(this));
if (inMobileMode && !$(this).hasClass('now_in_focus')) {
//console.log('doing in draggable', $(this));
desLogic.set_focus($(this));
uxController.openTextDrawer($(this).find('textarea'));
}
//console.log('repoooooosistioning now');
var thisDraggable = $(this);
//DZ 22may17: putting inside short short timeout, because of ME-55 bug in mobile (happens also on drag/move - sticky handle doesnt fit right place)
setTimeout(function () {
desLogic.reposition_sticky_handles(thisDraggable);
}, 25);
},
//new DZ29aug16:
drag: function (event, ui) {
//DZ 27mar17: for fixing dragging in scaled divs (see http://stackoverflow.com/questions/13882070/jquery-draggable-and-webkit-transform-scale)
//scaling fixes:
var zoom = desLogic.editor_scale;
var original = ui.originalPosition;
ui.position = {
left: (event.clientX - lastDragStartPos.x + original.left) / zoom,
top: (event.clientY - lastDragStartPos.y + original.top) / zoom
};
//console.log('ui.position', ui.position);
//var draggedElement = $(event.srcElement);
var draggedElement = $(ui.helper.context);
var textAreaColor = draggedElement.find('textarea').css('color');
//var dragged_left = parseFloat(draggedElement.css('left')) + parseFloat(draggedElement.css('margin-left'));
var dragged_left = ui.position.left + parseFloat(draggedElement.css('margin-left'));
//DZ 25sep16: had 14px difference in Admin:
//var dragged_width = parseFloat(draggedElement.css('width'));
var dragged_width = parseFloat(draggedElement.width()) + 2 * parseFloat(draggedElement.css('padding-left')) + 2 * parseFloat(draggedElement.css('border-left-width')); //14 is padding + border
var dragged_right = dragged_left + dragged_width;
var dragged_center = (dragged_left + dragged_right) / 2;
var dragged_top = ui.position.top;
//DZ 25sep16: had 14px difference in Admin:
//var dragged_bottom = ui.position.top + parseFloat(draggedElement.css('height'));
var dragged_height = parseFloat(draggedElement.height()) + 2 * parseFloat(draggedElement.css('padding-top')) + 2 * parseFloat(draggedElement.css('border-top-width')); //14 is padding + border
var dragged_bottom = ui.position.top + dragged_height;
var dragged_middle = (dragged_top + dragged_bottom) / 2;
var context_editor_frame = draggedElement.parents('.editorFrame');
var vert_lines_x_pos = new Array();
var hori_lines_y_pos = new Array();
var SNAP_SENSITIVITY = 5;
//var GRID_SENSITIVITY = 1;
var examined_decors = context_editor_frame.find('.slot_text.freesize,.decor_full_image');
//examined_decors.add(context_editor_frame);
//DZ 27mar17: setting max/min values - instead of "revert" option that we stopped using (doesnt work with transform:scale for mobile)
var minX = -dragged_width / 2;
var maxX = context_editor_frame.width() - (dragged_width / 2);
var minY = -dragged_height / 2;
var maxY = context_editor_frame.height() - dragged_height / 2;
//console.log(maxX);
if (ui.position.left < minX) {
console.log("DRAG minX");
ui.position.left = minX;
}
else if (ui.position.left > maxX) {
console.log("DRAG maxX", maxX);
ui.position.left = maxX;
}
if (ui.position.top < minY) {
console.log("DRAG minY");
ui.position.top = minY;
}
else if (ui.position.top > maxY) {
console.log("DRAG maxY");
ui.position.top = maxY;
}
var found_snappable_x = false;
var found_snappable_y = false;
//console.log('DRAG Started2', dragged_left, dragged_width);
for (var i = 0; i < examined_decors.length; i++) {
if (examined_decors[i] != draggedElement[0]) {
var checked_decor = $(examined_decors[i]);
var left = parseFloat(checked_decor.css('left')) + parseFloat(checked_decor.css('margin-left'));
if (isNaN(left)) left = 0; //fixed decor_full_image 'auto' css val in IE
//var width = parseFloat(checked_decor.css('width'));
var width = parseFloat(checked_decor.width()) + 2 * parseFloat(checked_decor.css('padding-left')) + 2 * parseFloat(checked_decor.css('border-left-width')); // + 14;
var right = left + width;
var center = (left + right) / 2.0;
//console.log('examining', examined_decors[i], left, width);
var top = parseFloat(checked_decor.css('top'));
if (isNaN(top)) top = 0; //fixed decor_full_image 'auto' css val in IE
//var height = parseFloat(checked_decor.css('height'));
var height = parseFloat(checked_decor.height()) + 2 * parseFloat(checked_decor.css('padding-top')) + 2 * parseFloat(checked_decor.css('border-top-width')); // + 14;
var bottom = top + height;
var middle = (top + bottom) / 2;
//console.log("DRAG examining ", left, center, right, top, middle, bottom);
//SNAPPING
//snapping to X if needed
if (!found_snappable_x) {
var snap_delta_x = center - dragged_center;
if (Math.abs(snap_delta_x) > SNAP_SENSITIVITY) {
snap_delta_x = left - dragged_left;
if (Math.abs(snap_delta_x) > SNAP_SENSITIVITY)
snap_delta_x = right - dragged_right;
}
//now snapDelta is the snap delta of center,left,right (prioritzed to this order)
if (snap_delta_x != 0 && Math.abs(snap_delta_x) <= SNAP_SENSITIVITY) {
found_snappable_x = true; //will stop after this - event will occur again
//console.log("Drag SNAPPED to ", checked_decor[0] ,ui, ui.position.left ," by delta ", snap_delta_x);
ui.position.left = ui.position.left + snap_delta_x;
//recalculate all fields to new snapped val:
dragged_left = dragged_left + snap_delta_x;
dragged_right = dragged_right + snap_delta_x;
dragged_center = dragged_center + snap_delta_x;
}
}
//snapping to Y if needed:
if (!found_snappable_y) {
var snap_delta_y = middle - dragged_middle;
if (Math.abs(snap_delta_y) > SNAP_SENSITIVITY) {
snap_delta_y = top - dragged_top;
if (Math.abs(snap_delta_y) > SNAP_SENSITIVITY)
snap_delta_y = bottom - dragged_bottom;
}
//now snapDelta is the snap delta of center,left,right (prioritzed to this order)
if (snap_delta_y != 0 && Math.abs(snap_delta_y) <= SNAP_SENSITIVITY) {
found_snappable_y = true; //will stop after this - event will occur again
//console.log("Drag SNAPPED_Y to ", checked_decor[0], ui, ui.position.left, " by delta ", snap_delta_y);
ui.position.top = ui.position.top + snap_delta_y;
//recalculate all fields to new snapped val:
dragged_top = dragged_top + snap_delta_y;
dragged_bottom = dragged_bottom + snap_delta_y;
dragged_middle = dragged_middle + snap_delta_y;
}
}
//if (found_snappable_x) console.log('snappedX');
//else if (found_snappable_y) console.log('snappedY');
//Adding vertical lines:
//DZ 15jan17: adding small deltas
if (center == dragged_center) vert_lines_x_pos.push(center);
if (left == dragged_left) vert_lines_x_pos.push(left + 2);
if (right == dragged_right) vert_lines_x_pos.push(right - 3);
//adding horizontal lines:
if (top == dragged_top) hori_lines_y_pos.push(top + 2);
if (middle == dragged_middle) hori_lines_y_pos.push(middle);
if (bottom == dragged_bottom) hori_lines_y_pos.push(bottom - 3);
//if (vert_lines_x_pos.length>0)
// console.log("Drag found vert lines", vert_lines_x_pos);
}
}
//clear previous snapping lines:
context_editor_frame.find('.snapper_line').remove();
//if (vert_lines_x_pos.length > 0 || hori_lines_y_pos.length.length > 0)
//{
// console.log('snap lines',hori_lines_y_pos, vert_lines_x_pos);
//}
$(vert_lines_x_pos).each(function (xPos) {
context_editor_frame.append($('
').addClass('snapper_line').addClass('ver').css({ 'left': this + 'px', 'border-color': textAreaColor }));
});
$(hori_lines_y_pos).each(function (yPos) {
context_editor_frame.append($('
').addClass('snapper_line').addClass('hor').css({ 'top': this + 'px', 'border-color': textAreaColor }));
});
} //end 'drag' handler
});
}
this.reinit_autosizer = function (jqCustomTextarea, forceAlignmentFix) {
//forceAlignmentFix is meant to be passed on font size slide event, to ensure alignemnt fix when sliding fontsize on freesize slots
//2 types of textboxes supported: custom (auto font change), and freesize (auto size change)
if (jqCustomTextarea.hasClass('custom_textarea')) {
//CUSTOM TEXTAREA SCENARIO
jqCustomTextarea.trigger('autosize.destroy').css('height', '1px').autosize({ append: '' });
}
else if (jqCustomTextarea.parent().hasClass('freesize')) {
////FREESIZE SCENARIO:
freesize_resize(jqCustomTextarea, forceAlignmentFix);
}
}
this.setColorToJQTextSlot = function (jqTextSlot, newColor) {
jqTextSlot.css('outline-color', get_outline_color(newColor));
//data - before - bg - color
//the BG for the "before" pseudo element will be "inherited" from here
//jqTextSlot.attr('data-before-bg-color', 'blue');
var newColorRgb;
if (newColor.indexOf('rgb') >= 0)
newColorRgb = hexToRgb(rgb2hex(newColor));
else
newColorRgb = hexToRgb(newColor);
var needsDarkBG = colorRequiresDarkBG(newColorRgb);
if (needsDarkBG)
jqTextSlot.addClass('dark-text-bg');
else
jqTextSlot.removeClass('dark-text-bg');
}
//PRIVATE:
function colorRequiresDarkBG(rgb) {
//TODO 6feb17: this is now overridden by new CSS for (supposdely) only inner sides decors. wait for fb from natali in invision, remove if needed.
//TODO #2: some new places still use old sprite(s)
//rgb = Array.prototype.join.call(arguments).match(/(-?[0-9\.]+)/g);
//for (var i = 0; i < rgb.length; i++) {
// rgb[i] = (i === 3 ? 1 : 255) - rgb[i];
//}
//var ret =
// {
// r: 255 - rgb.r,
// g: 255 - rgb.g,
// b: 255 - rgb.b,
// };
//LUMA algo:
//var rgb = (typeof color === 'string') ? hexToRGBArray(color) : color;
//return (0.2126 * rgb.r) + (0.7152 * rgb.g) + (0.0722 * rgb.b); // SMPTE C, Rec. 709 weightings
//var ret =
// {
// r: parseInt( 0.2126 * rgb.r),
// g: parseInt( 0.7152 * rgb.g),
// b: parseInt(0.0722 * rgb.b)
// };
//YIQ contrast: (https://24ways.org/2010/calculating-color-contrast/)
//var r = parseInt(hexcolor.substr(0, 2), 16);
//var g = parseInt(hexcolor.substr(2, 2), 16);
//var b = parseInt(hexcolor.substr(4, 2), 16);
var yiq = ((rgb.r * 299) + (rgb.g * 587) + (rgb.b * 114)) / 1000;
return (yiq >= 128);
//? { r: 0, g: 0, b: 0 }: { r: 255, g: 255, b: 255 };
}
//PRIVATE - DZ 16mar17: copying alot of JS that floated inside CSHTML file
function initEditorEvents() {
//'designer.save'
//'designer.send'
//'designer.print'
//'designer.download'
window.receivedEvents = [];
function eventHandler(event, data) {
var oevent = { event: event, data: data, cardId: cardId, categoryId: categoryId, sectionId: sectionId };
var dstr = JSON.stringify({ cardId: cardId, categoryId: categoryId, sectionId: sectionId });
if (receivedEvents.indexOf(dstr) === -1 && $.cookie('CategoriesVisit') !== null) {
$.post('..\\card\\event.html', oevent);
receivedEvents.push(dstr);
}
};
//YZ 20/6/17 - showing a 'share us' dialog - after download or print (desktop only)
function show_shareus_dialog() {
setTimeout(function () {
if (!inMobileMode)
uxController.show_popup_centered($('#popup_share_us'));
}, 1500);
}
$.subscribe('designer.save.done', function (e, d) { eventHandler('designer.save.done', d); });
$.subscribe('designer.send', function (e, d) { eventHandler('designer.send', d); });
$.subscribe('designer.print', function (e, d) { eventHandler('designer.print', d); });
$.subscribe('designer.download', function (e, d) { eventHandler('designer.download', d); show_shareus_dialog(); });
$.subscribe('designer.print', function (e, editor_mode, custom_params) {
//invites
if (editor_mode === 'invitations') {
ga('send', 'event', 'designer.invitations', 'print', { "dimension1": custom_params['invites_per_page'] });
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\print\\index.html' + custom_params['invites_per_page'] + '_perPage');
show_shareus_dialog();
}
//cards
else {
//d2 is page1 page2 or duplex
ga('send', 'event', 'designer.' + editor_mode, 'print', { "dimension12": custom_params['pageNum'], "dimension10": custom_params['current_print_page_size_mode'], "dimension11": custom_params['current_page_type'] });
if (custom_params['pageNum'] !== "page1") {
show_shareus_dialog();
}
}
});
$.subscribe('designer.download_click', function (e, editorMode) {
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\download.html');
});
$.subscribe('designer.download_fileType', function (e, fileType) {
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\download\\index.html' + fileType);
});
$.subscribe('designer.download', function (e, editorMode, fileType, current_print_page_size_mode, current_page_type) {
//DZ 11sep17: ecardsv2 support
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode === "cards" || editorMode === "ecards" || editorMode== "ecards_v2") {
if (editorMode === "cards" || editorMode == "ecards") {
ga('send', 'event', 'designer.' + editorMode, 'download', { "dimension2": fileType, "dimension10": current_print_page_size_mode, "dimension11": current_page_type });
} else {
if ($.cookie('order_complete') !== "true") {
if (window.CouponDialog)
setTimeout(function () { CouponDialog.show(); }, 5000);
}
ga('send', 'event', 'designer.' + editorMode, 'download', { "dimension2": fileType });
if (fileType === "pdf") {
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\download\\pdf\\index.html' + current_print_page_size_mode + '_perPage');
} else {
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\download\\index.html' + fileType);
}
}
});
//DZ 27agu17: adding missing handler
$.subscribe('designer.download_premium', function (e, editorMode, fileType, num_per_page) {
//DZ 11sep17: ecardsv2 support
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode === "cards" || editorMode === "ecards" || editorMode == "ecards_v2") {
if (editorMode === "cards" || editorMode == "ecards") {
ga('send', 'event', 'designer.' + editorMode, 'download_premium', { "dimension2": fileType, "dimension10": num_per_page, "dimension11": current_page_type });
} else {
ga('send', 'event', 'designer.' + editorMode, 'download_premium', { "dimension2": fileType });
}
});
$.subscribe('designer.save.click', function () {
ga('send', 'pageview', '..\\virtual\\index.html' + editorMode + '..\\designer\\save.html');
});
$.subscribe('designer.save.done', function (e, editorMode, savedJSON) {
ga('send', 'event', 'designer.' + editorMode, 'save');
});
$.subscribe('designer.send', function (e, editorMode, send_type) {
if (typeof send_type !== "undefined")
ga('send', 'event', 'designer.' + editorMode, 'send_online', send_type);
else
ga('send', 'event', 'designer.' + editorMode, 'send_online');
});
//DZ 21jan18: no more pixter
//$.subscribe('pixter.pixterInitDone', function () {
// //if order params - auto-show pxiter dialog
// if (getParameterByName('order') != '') {
// if (requiresLogin == 'True') {
// authenticate().done(function (d) {
// //window.location = window.location.toString().split(/[?#]/)[0] + '/' + '@TempData["cardCode"]' + '?order=1';
// window.location = window.location.toString().split(/[?#]/)[0] + '/' + pageArgCardCode + '?order=1';
// });
// } else {
// if ($('body').hasClass('now_initing')) { //designer still initiating
// $.subscribe('designer.loadComplete', function () {
// printOrder();
// });
// } else { //designer ready
// printOrder();
// }
// }
// }
//});
}
//PUBLIC
this.get_template_slot_photoFront = function () {
return $('#template_slot_photoFront').clone().removeAttr('id');
}
//PUBLIC
this.get_template_slot_photo = function () {
return $('#template_slot_photo').clone().removeAttr('id');
}
//PUBLIC
this.get_template_slot_text = function () {
return $('#template_slot_text').clone().removeAttr('id');
}
//PRIVATE
function loadInitialFonts(succFunc) {
//this method replaces the old WebFontLoaded method. it decides which fonts should be loaded, loads them and continues
var fontNames = getRelevantFontsForUserContext();
console.log("FONTS initial ", fontNames);
thisController.loadFonts(fontNames, succFunc);
}
//PUBLIC
this.loadFonts = function (fontsToLoad, succFunc) {
//here we define which fonts are from google, and which are local
//YZ 7/11/18 - Mountains of Christmas must be written with 'of' not 'Of' since otherwise it will be broken when trying to get font from google (cie-309)
var config_googleFonts = ['Lato', 'Cinzel', 'Spicy Rice', 'Alex Brush', 'Luckiest Guy', 'Mountains of Christmas', 'Patrick Hand', 'Meddon', 'Yesteryear', 'Sail', 'Vast Shadow', 'Quicksand', 'Ribeye Marrow', 'Parisienne', 'Kreon', 'Libre Baskerville', 'Bentham', 'Stint Ultra Expanded'];
var googleFontNames = new Array();
var customFontNames = new Array();
var customFontUrls = new Array();
for (var i = 0; i < fontsToLoad.length; i++) {
//removing quotes from font names
var fontName = strreplace(fontsToLoad[i], "'", "");
//DZ 8may18: hotfixing. for 'intuitive' (as seen in "Jack & Lisa" (maybe more), font name is displayed wrong, file name is 'Intuitive.css"
//console.log("SAASDASD", fontName)
if (fontName === 'intuitive') {
console.log('hotfixing font name "intuitive"');
fontName == 'Intuitive';
}
if ($.inArray(fontName, fontsAlreadyLoaded) >= 0) {
console.log("FONTS font already loaded", fontName);
}
else {
fontsAlreadyLoaded.push(fontName);
//DZ 11mar18: SAM code merge - changing the way fonts are loaded a bit:
// if ($.inArray(fontName, config_googleFonts) >= 0)
// googleFontNames.push(fontName);
// else {
// customFontNames.push(fontName);
// //var url = "..\\Images\\new_editor\\fonts\\index.html" + strreplace(fontName, ' ',''MS_7803.css"
// var url = "..\\Editor\\images\\fonts\\index.html" + strreplace(fontName, ' ', ''MS_7803.css"
// customFontUrls.push(url);
var isAGoogleFont = $.inArray(fontName, config_googleFonts) >= 0;
if (editorAppMode !== "SAM") {
if (isAGoogleFont)
googleFontNames.push(fontName);
else {
customFontNames.push(fontName);
customFontUrls.push("..\\Editor\\images\\fonts\\index.html" + strreplace(fontName, ' ', '') + ".css");
}
}
else {
//DZ 30nov17: MOBAPP - not using google fonts from mobile mode - all fonts are treated as custom
customFontNames.push(fontName);
if (isAGoogleFont)
customFontUrls.push("fonts\\google\\index.html" + strreplace(fontName, ' ', '') + ".css");
else
customFontUrls.push("fonts\\other\\index.html" + strreplace(fontName, ' ', '') + ".css");
}
////DZ 30nov17: MOBAPP - not using google fonts from mobile mode
//if (editorAppMode !== "SAM" && isAGoogleFont)
// googleFontNames.push(fontName);
//else {
// customFontNames.push(fontName);
// //var url = "..\\Images\\new_editor\\fonts\\index.html" + strreplace(fontName, ' ',''MS_7803.css"
// if (editorAppMode === "SAM") {
// if (!isAGoogleFont)
// customFontUrls.push("fonts\\other\\index.html" + strreplace(fontName, ' ', '') + ".css");
// else
// customFontUrls.push("fonts\\google\\index.html" + strreplace(fontName, ' ', '') + ".css");
// }
}
}
if (googleFontNames.length == 0 && customFontNames.length == 0) {
console.log("FONTS no fonts needed to be loaded");
succFunc();
}
else {
console.log("FONTS loading", googleFontNames, customFontNames, customFontUrls);
var webFontSettings = {
active: function () {
console.log("WebFont ALL LOADED", fontsToLoad);
//DZ 28may17: (ME-54 / CIE-212) - safari devices dont finish loading fonts when webfonts active event fires - using older code to validate real loading
//costs about 400ms - doing it only for safari
//succFunc();
var isSafari = sayswho().indexOf('Safari') > -1;
//DZ 22jun17: fix from 28may17 didnt fix 100% of times. what happened (ME-115): for Cinzel, in first run of WebFontLoaded comparison, newWidth was 803, and set to 394 only on second check.
//so font size was changed from default size (420) - but was in the wrong size at first.
//this is a hack. real reason for font not loaded right on safari is still unknown.
if (isSafari)
WebFontLoaded(fontsToLoad, function () {
setTimeout(function () {
WebFontLoaded(fontsToLoad, function () {
succFunc();
});
}, 100);
});
else
succFunc();
},
//fontloading: function(familyName, fvd) {},
fontactive: function (familyName, fvd) { console.log("WebFont fontactive", familyName) },
fontinactive: function (familyName, fvd) { console.error("WebFont fontinactive", familyName, fvd) },
};
if (googleFontNames.length > 0) webFontSettings.google = { families: googleFontNames };
if (customFontNames.length > 0)
webFontSettings.custom = {
families: customFontNames,
urls: customFontUrls
};
WebFont.load(webFontSettings);
}
}
//PRIVATE
function getRelevantFontsForUserContext() {
//get all relevant fonts from design and user load
var fontNames = new Array();
var card_idx;
//DZ 15feb17: Arimo is our default font, so adding it (ND-144)
fontNames.push(getFontName('arimoregular'));
if (cardDesign == null && typeof orderDesign == "undefined") {
//YZ 15-12-16 : skipping if no pages defined - for admin to work properly
if (cardConfig.pages !== null) {
//CARD ORIGINAL DESIGN
for (card_idx = 0; card_idx < cardConfig.pages.length; card_idx++) {
var textFields = cardConfig.pages[card_idx].fields;
$(textFields).each(function () {
if ($.inArray(this.font, fontNames) < 0) {
fontNames.push(getFontName(this.font));
}
});
}
}
}
else {
var jsonDesign = typeof orderDesign !== "undefined" ? orderDesign.cardDesign : cardDesign;
console.log("loading fonts from cardDesign", cardDesign);
//loading from saved card design
$(jsonDesign.pages).each(function (page) {
if (jsonDesign.pages[page].textElements) {
//console.log('tw', page.textElements);
$(jsonDesign.pages[page].textElements).each(function (fieldIdx) {
var field = jsonDesign.pages[page].textElements[fieldIdx];
if ($.inArray(field.font, fontNames) < 0)
fontNames.push(getFontName(field.fontFamily));
});
}
})
}
return fontNames;
}
//textbox'es outline shuld be transparent a bit
//DZ 11jan17: REDESIGN
function get_outline_color(color) {
//color input should be #rrggbb format (with #)
//fallback:
var a = 0.95;
var newColor = 'rgba(128,128,128,' + a + ')';
try {
//normalizing to rgb:
var rgb;
if (color.indexOf('rgb') >= 0)
rgb = hexToRgb(rgb2hex(color));
else
rgb = hexToRgb(color);
var fixColor = function (clr) {
//brightn it up:
var diff = 255 - clr;
var delta = diff * 0.5;
return Math.round(clr + delta);
}
newColor = 'rgba(' + fixColor(rgb.r) + ',' + fixColor(rgb.g) + ',' + fixColor(rgb.b) + ',' + a + ')';
}
catch (e) {
debug.error('using fallback. failed getting outline-color for ', color, e);
}
debug.log('get_outline_color ', color, newColor);
return newColor;
}
//PUBLIC
//front/inside/back tabs (AKA change_tab)
this.change_editor_tab = function (tabname) {
//active tab window :
$('.editorTab').removeClass('active');
$('.editorTab[tab="' + tabname + '"]').addClass('active');
if (!inMobileMode) {
//DESKTOP MDOE
//tab selector:
//DZ 2jan17 redesign
$('.card_pages_selector a').removeClass('-active');
$('.card_pages_selector a[tab="' + tabname + '"]').addClass('-active');
}
else {
// tab selector:
$('.item-sides a').removeClass('-active');
$('.item-sides a[tab="' + tabname + '"]').addClass('-active');
//DZ 15mar18: (SAM) made loaded saves have 'right' arrow:
//var showArrows = tabname != 'inside' || getLayout() == 'landscape';
var showArrows = editorMode === 'cards' && (tabname != 'inside' || getLayout() == 'landscape');
$('.editor-arrows').toggle(showArrows);
$('.editor-arrows .-arrow-left').toggle(tabname != 'front');
$('.editor-arrows .-arrow-right').toggle(tabname != 'back');
desLogic.sendTactileEvent('card-tab-selected');
//uxController.close_all_drawers();
}
desLogic.close_popups_or_drawers();
//hotfix textareas: for pre-set texts in inner pages they are initially initted while invisible, so now we re-init them to fix positioning
//DZ: 1oct14: using same line from her before printing. otherwise we wad rare text offsets moving around
desLogic.reinit_autosizer($('.slot_text:visible textarea.custom_textarea:visible'));
//reset any previous focuses:
desLogic.reset_focus();
}
//PUBLIC
this.reset_focus = function () {
console.log('resseting focus');
$('.now_in_focus').removeClass('now_in_focus');
//for mobile, we close any drawers here:
//if (inMobileMode && dontCloseDrawers!==true)
// uxController.close_all_drawers();
};
//PUBLIC
this.set_focus = function (jqElement) {
//DZ 15may17: added condition. might help avoid some issues:
if (!jqElement.hasClass('now_in_focus')) {
thisController.reset_focus();
jqElement.addClass('now_in_focus');
desLogic.sendTactileEvent('decor-selected');
}
}
//PRIVATE
function bind_layouts() {
//define layouts:
var current_layout = getLayout();
//REDESIGNED was -17
var bgLeft = '-19px '; //remebmer space
/*DZ::after 10jun14 changing from img to div with bg*/
//NEW LAYOUTS
//width & left are optional (css set values)
var full_page_text = [{ type: 'text', top: '5%', height: '90%' }];
var full_page_image = [{ type: 'image', top: '0%', height: '100%', left: '0%', width: '100%' }];
//DZ 27feb18: [CIE-268] - only portrait gets this treatment (bigger text margins in layout) for now
if (current_layout == 'portrait')
full_page_text = [{ type: 'text', top: '5%', height: '90%', width: '80%', left: '10%' }];
//DZ 11sep17: same as ecards from now
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'cards' || editorMode =='ecards_v2') {
if (editorMode == 'cards' || editorMode == 'ecards') {
//==== LAYOUTS FOR CARDS ====
var layoutsSpriteFilename = 'Layout-Sprite.png';
if (current_layout == 'landscape') {
bgLeft = '-39px '; //notice space
//LANDSCAPE/WIDE CARDS LAYOUTS:
jsonLayouts = [
//blank / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -883,
inner_left: [],
inner_right: full_page_text
},
//2
{
thumb_src: layoutsSpriteFilename, thumb_y: -1043,
inner_left: full_page_text,
inner_right: full_page_text
},
//3
{
thumb_src: layoutsSpriteFilename, thumb_y: -1203,
inner_left: full_page_image,
inner_right: full_page_text
},
//4
{
thumb_src: layoutsSpriteFilename, thumb_y: -1363,
inner_left: [{ type: 'image', top: '5%', height: '90%', width: '90%' }],
inner_right: full_page_text
},
//5
{
thumb_src: layoutsSpriteFilename, thumb_y: -1524,
inner_left: [
{ type: 'image', top: '10%', height: '65%', width: '70%', left: '15%' },
{ type: 'text', top: '75%', height: '15%', width: '70%', left: '15%' }
],
inner_right: full_page_text
},
//6
{
thumb_src: layoutsSpriteFilename, thumb_y: -1684,
inner_left: [{ type: 'image', top: '5%', height: '91%', width: '38%' }, { type: 'text', top: '5%', height: '90%', width: '49%', left: '46%' }],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -1844,
inner_left: [{ type: 'image', top: '10%', height: '35%', width: '30%' }, { type: 'text', top: '10%', height: '35%', width: '55%', left: '40%' },
{ type: 'image', top: '55%', height: '35%', width: '30%' }, { type: 'text', top: '55%', height: '35%', width: '55%', left: '40%' }],
inner_right: full_page_text
}
]
}
else if (current_layout == 'square') {
//SQUARE CARDS LAYOUTS:
bgLeft = '-19px '; //notice space
jsonLayouts = [
//blank / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -2015,
inner_left: [],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -2105,
inner_left: full_page_text,
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -2195,
inner_left: full_page_image,
inner_right: full_page_text
},
{
//almost (90%) full image:
thumb_src: layoutsSpriteFilename, thumb_y: -2285,
inner_left: [{ type: 'image', top: '5%', height: '90%', width: '90%' }],
inner_right: full_page_text
},
{
//photo top, text bottom
thumb_src: layoutsSpriteFilename, thumb_y: -2375,
inner_left: [{ type: 'image', top: '5%', height: '75%' }, { type: 'text', top: '80%', height: '15%' }],
inner_right: full_page_text
},
{
//text top, photo bottom
thumb_src: layoutsSpriteFilename, thumb_y: -2465,
inner_left: [{ type: 'text', top: '5%', height: '15%' }, { type: 'image', top: '21%', height: '75%' }],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -2555,
inner_left: [{ type: 'image', top: '20%', height: '45%' }, { type: 'text', top: '65%', height: '15%' }],
inner_right: full_page_text
},
{
//tall image:
thumb_src: layoutsSpriteFilename, thumb_y: -2645,
inner_left: [{ type: 'image', top: '10%', height: '80%', width: '64%', left: '18%' }],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -2735,
inner_left: [{ type: 'image', top: '10%', height: '65%', width: '60%', left: '20%' }, { type: 'text', top: '75%', height: '15%', width: '80%', left: '10%' }],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -2825,
inner_left: [{ type: 'image', top: '10%', height: '35%', width: '35%' }, { type: 'text', top: '10%', height: '35%', width: '50%', left: '45%' },
{ type: 'image', top: '55%', height: '35%', width: '35%' }, { type: 'text', top: '55%', height: '35%', width: '50%', left: '45%' }
],
inner_right: full_page_text
}
]
}
else {
//NORMAL CARD LAYOUTS:
jsonLayouts = [
//blank / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -43,
inner_left: [],
inner_right: full_page_text
},
// full text / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -163,
inner_left: full_page_text,
inner_right: full_page_text
},
//full image / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -283,
inner_left: full_page_image,
inner_right: full_page_text
},
//full pic with caption / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -403,
//DZ 27feb18: [CIE-268]
//inner_left: [{ type: 'image', top: '5%', height: '80%' }, { type: 'text', top: '85%', height: '10%' }],
inner_left: [{ type: 'image', top: '5%', height: '80%' }, { type: 'text', top: '85%', height: '10%', width: '80%', left: '10%' }],
inner_right: full_page_text
},
//small pic with caption / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -523,
//DZ 27feb18: [CIE-268]
//inner_left: [{ type: 'image', top: '25%', height: '40%' }, { type: 'text', top: '65%', height: '10%' }],
inner_left: [{ type: 'image', top: '25%', height: '40%' }, { type: 'text', top: '65%', height: '10%', width: '80%', left: '10%' }],
inner_right: full_page_text
},
//two images with captions / full text
{
thumb_src: layoutsSpriteFilename, thumb_y: -643,
inner_left: [
//DZ 27feb18: [CIE-268]
//{ type: 'image', top: '4.5%', height: '38%' },
//{ type: 'text', top: '42.69%', height: '6.5%' },
//{ type: 'image', top: '51.5%', height: '38%' },
//{ type: 'text', top: '89.5%', height: '6.5%' }],
{ type: 'image', top: '4.5%', height: '38%' },
{ type: 'text', top: '42.69%', height: '6.5%', width: '80%', left: '10%' },
{ type: 'image', top: '51.5%', height: '38%' },
{ type: 'text', top: '89.5%', height: '6.5%', width: '80%', left: '10%' }],
inner_right: full_page_text
},
{
thumb_src: layoutsSpriteFilename, thumb_y: -763,
inner_left: [
{ type: 'image', top: '5%', height: '28%', width: '44%' },
{ type: 'image', top: '36%', height: '28%', width: '44%' },
{ type: 'image', top: '68%', height: '28%', width: '44%' },
{ type: 'text', top: '5%', height: '27%', width: '42%', left: '53%' },
{ type: 'text', top: '36%', height: '27%', width: '42%', left: '53%' },
{ type: 'text', top: '68%', height: '27%', width: '42%', left: '53%' }
],
inner_right: full_page_text
}
];
}
}
//DZ 20nov17: commetning all this if branch. migrating from 'ecards v2' to 'ecards' (losing old behavior)
//else if (editorMode == 'ecards') {
// var layoutsSpriteFilename = 'Ecard-Layout-Sprite.png';
// //==== LAYOUTS FOR ECARDS ====
// if (current_layout == 'landscape') {
// //LANDSCAPE ECARD LAYOUT
// bgLeft = "-40px "; //notice space
// jsonLayouts = [
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -415,
// inner_right: full_page_text
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -575,
// inner_right: [{ type: 'image', top: '15%', height: '50%', width: '60%', left: '20%' }, { type: 'text', top: '65%', height: '20%' }],
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -735,
// inner_right: [{ type: 'image', top: '5%', height: '60%', width: '60%', left: '20%' }, { type: 'text', top: '65%', height: '30%' }],
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -895,
// inner_right: [{ type: 'image', top: '5%', height: '90%', width: '30%' }, { type: 'text', top: '5%', height: '90%', width: '55%', left: '40%' }]
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -1055,
// inner_right: [{ type: 'image', top: '10%', height: '35%', width: '30%' }, { type: 'text', top: '10%', height: '35%', width: '55%', left: '40%' },
// { type: 'image', top: '55%', height: '35%', width: '30%' }, { type: 'text', top: '55%', height: '35%', width: '55%', left: '40%' }]
// }
// ];
// }
// else if (current_layout == 'square') {
// //SQUARE ECARD LAYOUT
// bgLeft = '-13px ';
// jsonLayouts = [
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -1221,
// inner_right: full_page_text
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -1319,
// inner_right: [{ type: 'image', top: '5%', height: '45%' }, { type: 'text', top: '50%', height: '45%' }]
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -1416,
// inner_right: [{ type: 'image', top: '50%', height: '45%' }, { type: 'text', top: '5%', height: '45%' }]
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -1514,
// inner_right: [{ type: 'image', top: '5%', height: '45%', width: '70%', left: '15%' }, { type: 'text', top: '50%', height: '45%' }]
// }
// ];
// }
// else {
// //NORMAL ECARD LAYOUT
// jsonLayouts = [
// //blank / full text
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -43,
// inner_right: full_page_text
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -163,
// inner_right: [{ type: 'image', top: '5%', height: '43%' }, { type: 'text', top: '52%', height: '43%' }]
// },
// {
// thumb_src: layoutsSpriteFilename, thumb_y: -283,
// inner_right: [{ type: 'text', top: '5%', height: '43%' }, { type: 'image', top: '52%', height: '43%' }]
// }
// ];
// }
//}
else
debug.error('bindLayouts - unhandled editorMode: ' + editorMode);
var idx = 0;
//for mobile we show x0.5 size
if (inMobileMode)
bgLeft = parseFloat(bgLeft.replace('px', '')) * 0.5 + 'px ';
$(jsonLayouts).each(function () {
var thisLayout = this;
if (inMobileMode) {
//DZ 11mar18: SAM code merge:
//DZ 5dec17 (SAM):
var layoutUrlPrefix = '';
if (editorAppMode !== "SAM")
layoutUrlPrefix = '..\\Editor\\index.html';
//for mobile we show x0.5 size
var newDiv = $('
').addClass('layout').attr('layout_id', idx).css({
//'background-image': 'url(..\\Editor\\images\\index.html' + thisLayout.thumb_src + ')',
'background-image': 'url(' + layoutUrlPrefix + 'images\\index.html' + thisLayout.thumb_src + ')',
'background-repeat': 'no-repeat',
'background-position': bgLeft + (thisLayout.thumb_y * 0.5) + 'px'
});
var targetGroup = $('#layouts_row_' + (idx % 2));
targetGroup.append(newDiv);
}
else {
var newDiv = $('').addClass('layout').attr('layout_id', idx).css({
//'background-image': 'url(..\\images\\new_editor\\index.html' + thisLayout.thumb_src + ')',
//'background-image': 'url(..\\Editor\\images\\new_editor\\index.html' + thisLayout.thumb_src + ')',
'background-image': 'url(..\\Editor\\images\\index.html' + thisLayout.thumb_src + ')',
'background-repeat': 'no-repeat',
'background-position': bgLeft + thisLayout.thumb_y + 'px'
});
//$('.layouts_scrollable').append(newDiv);
$('#layouts_holder').append(newDiv);
}
idx++;
});
//bind first layout as default:
thisController.bind_layout(0);
$('#layouts_holder .layout').click(function () {
var layoutid = $(this).attr('layout_id');
//DZ 25aug15: only if really changing the current layout:
var currentLayoutId = $('body').attr('selected_card_layout');
if (currentLayoutId != layoutid)
thisController.bind_layout(layoutid);
else
debug.log("same layout id clicked - ignoring");
});
//DZ 17aug14: change card thumbnail on ecards layouts
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == "ecards") {
// if (cardConfig != null && cardConfig.pages.length > 0 && cardConfig.pages[0] != null) {
// var cardImageUrl = cardConfig.pages[0].name;
// //$('.layouts_scrollable .layout').append($('
![]()
').addClass('layout_overlay').attr('src', cardImageUrl));
// $('#layouts_holder .layout').append($('
![]()
').addClass('layout_overlay').attr('src', cardImageUrl));
// }
//}
}
//PUBLIC
//bind a specific layout to the inside pages
this.bind_layout = function (layoutIdx) {
//all slots exists, we just show/hide the items of the layout
//DZ 1mar15: putting selected layout here:
$('body').attr('selected_card_layout', layoutIdx);
//DZ 15jan17: active class for layouts:
//DZ 29mar17: unifuying with mobile
//$('#layouts_sidebox .layout.active').removeClass('active');
//$('#layouts_sidebox .layout[layout_id=' + layoutIdx + ']').addClass('active');
$('#layouts_holder .layout.active').removeClass('active');
$('#layouts_holder .layout[layout_id=' + layoutIdx + ']').addClass('active');
//"private" method: bind specific layout
var bind_layout_to_frame = function (layout_arr, frame) {
//hide all current slots:
frame.find('.card_decor:not(.sticker_container):not(.decor_watermark)').addClass('invis');
var imgIdx = 0;
var txtIdx = 0;
$(layout_arr).each(function () {
var slotMetaData = this;
var slotDiv;
if (slotMetaData.type == 'image') {
slotDiv = frame.find('.slot_photo:eq(' + imgIdx + ')');
imgIdx++;
}
else if (slotMetaData.type == 'text') {
slotDiv = frame.find('.slot_text:eq(' + txtIdx + ')');
txtIdx++;
}
else
debug.error('unknown slot type ' + slotMetaData.type, slotMetaData);
slotDiv.removeClass('invis').css({ top: slotMetaData.top, height: slotMetaData.height });
//left & width are optional
if (slotMetaData.left)
slotDiv.css('left', slotMetaData.left);
else
slotDiv.css('left', '');
if (slotMetaData.width)
slotDiv.css('width', slotMetaData.width);
else
slotDiv.css('width', '');
//DUPLICATE LOGIC IN add_image_to_context_slot_image
//fix pre-populatedd image proprotions (set to width OR height = 100%, but now width and height are changed, so a fix might be needed.
if (slotDiv.hasClass('slot_photo') && slotDiv.find('.photo_holder img').length > 0) {
var contextImg = slotDiv.find('.photo_holder img');
thisController.init_image_size_in_box_container(contextImg);
//reinit:
contextImg.panzoom('reset');
thisController.panzoom_init_image(contextImg);
//another hotfix for frames: if full shape frame, then sometimes need to fix tall/wide stuff
if (slotDiv.find('.slot_frame_shape_layer').length > 0) {
var frame_name = slotDiv.attr('current_frame');
thisController.bind_frame_to_slot_photo(slotDiv, frame_name);
}
}
debug.log('done');
})
};
if (!inMobileMode)
uxController.close_all_popups();
//(not needed in mobile)
//binding each layout
var layout = jsonLayouts[layoutIdx];
//left card is done only for cards (not for ecards)
//DZ 11sep17: ecardsv2 support
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'cards' || editorMode == "ecards_v2")
if (editorMode == 'cards' || editorMode == "ecards")
bind_layout_to_frame(layout.inner_left, $('.tabInside .editorFrame:first'));
bind_layout_to_frame(layout.inner_right, $('.tabInside .editorFrame:last'));
//DZ 23jun14: auto-resizing text when changing layout
//thisController.reinit_autosizer($('.slot_text:visible textarea:visible'));
//DZ 3sep14: commented
desLogic.reinit_autosizer($('.slot_text:visible textarea.custom_textarea:visible'));
//DZ 14sep14: uncommented , moved to this line (after reinit):
$('.slot_text:visible textarea.custom_textarea:visible').trigger('keyup');
desLogic.mark_as_dirty();
}
//jqElement here is textarea
//this method relevant only to custom_textareas (not freesize)
this.auto_change_textarea_font_size = function (jqElement) {
var slot_height = jqElement.parents('.slot_text').outerHeight();
var textbox_height = jqElement.height();
//debug.log('jqElement', jqElement, 'slot_height', slot_height, 'textbox_height', textbox_height);
var isdirty = false;
while (textbox_height > slot_height) {
//console.log('dada', textbox_height, slot_height);
isdirty = true;
var current_font_size = parseInt(jqElement.css('font-size').replace('px'));
jqElement.css({
'font-size': (current_font_size - 1) + 'px',
'line-height': lineHeightMultiplier(current_font_size - 1, getFontName(jqElement.css('font-family'))) + 'px'
});
//DZ 6aug14: not working (on keyup handler we dont have current_target set)
//thisController.reinit_autosizer(desLogic.text_design_popup_current_target);
desLogic.reinit_autosizer(jqElement);
textbox_height = jqElement.height();
}
if (isdirty) {
if (!inMobileMode) {
//DZ 30mar17: reducing font size beyond slider's minimum auto updated size to minimum, causing a loop (ND-263 Script on the Card's page stopped responding after trying to fill text with many new lines)
//$('#slider_fontsize').slider({ value: parseInt(jqElement.css('font-size').replace('px', '')) });
var newFontSize = parseInt(jqElement.css('font-size').replace('px', ''));
if (newFontSize >= SLIDER_MIN_FONT_SIZE)
//DZ 21may17 (18may17 too): new fontsize slider
//$('#slider_fontsize').slider({ value: newFontSize });
$('#slider_fontsize').slider({ value: desLogic.scaleFontSizeToSlider(newFontSize) });
else {
//sub minimum font change - change only slider's tooltip
$('#slider_fontsize .slider-tooltip').text(newFontSize + 'px');
}
}
//DZ 13aug14: if font size was changed because of text entry, then dont revert it
desLogic.mark_this_text_font_size_as_non_revetable();
debug.log('auto_change_textarea_font_size ', parseInt(jqElement.css('font-size')));
}
//returning final font px
return parseInt(jqElement.css('font-size').replace('px', ''));
}
//PUBLIC
//loadfromsave, loadcardfrom, load user save, loadsave, loadusersave
this.load_json_to_editor = function (importJson, loadSuccFunc) {
console.log('importing JSON', importJson);
//clear current design:
//remove all stickers:
$('.editorFrame .sticker_container').remove();
//remove all movable text slots
$('.editorFrame .slot_text.freesize').remove();
//clear all custom textareas:
$('.editorFrame .slot_text .custom_textarea').val('');
//clear all custom images (taken from image delete button handler - not tested, shouldnt interfere because we dont load into existing user worked design)
$('.editorFrame .slot_photo.has_photo')
.removeAttr('unfiltered_src')
.removeAttr('filter_name')
.removeAttr('current_frame')
.removeClass('has_photo')
$('.editorFrame .slot_photo').find('.slot_frame_corner,.slot_frame_shape_layer,.slot_frame_line').remove();
if (importJson.selectedLayoutIdx) {
debug.log('binding layout from import', importJson.selectedLayoutIdx);
desLogic.bind_layout(importJson.selectedLayoutIdx);
}
var recursive_page_handler = function (pageIdx, pageSuccFunc) {
//END CONDITION
if (pageIdx >= importJson.pages.length) {
console.log('recursive_page_handler - end cond');
pageSuccFunc();
}
else {
console.log("recursive_page_handler P# " + pageIdx, importJson.pages[pageIdx]);
var pageJson = importJson.pages[pageIdx];
var isFirstPage = false;
var jqFrame = $('.editorFrame:eq(' + pageIdx + ')');
//change tab to relevant tab:
switch (pageIdx) {
case 0:
isFirstPage = true;
desLogic.change_editor_tab('front');
break;
case 1:
desLogic.change_editor_tab('inside');
break;
case 2:
desLogic.change_editor_tab('inside');
break;
case 3:
desLogic.change_editor_tab('back');
break;
}
console.log('LOAD_FROM_JSON - stickers');
$(pageJson.stickerElements).each(function () {
var stickerElement = this;
var stickerSrc = this.src;
//DZ 4jan18: DC-93 - if sticker was never resized, MIGHT be saved without 'height'
var hei = stickerElement.height;
if (!hei || hei === '0px') {
console.log('AUTO FIXING HEIGHT FOR STICKER', stickerElement);
hei = 'auto';
}
//DZ 13mar17: fixing old saves, with old stickers URLs:
//old (bad) url example: "/images/new_editor/stickers/Animals/Animals007.svg"
//new (good) url: "/Editor/images/Stickers/Animals/Animals007.svg"
//if (stickerSrc != null && stickerSrc.indexOf('..\\images\\new_editor\\stickers\\index.html') >= 0)
// stickerSrc = stickerSrc.replace("..\\images\\new_editor\\stickers\\index.html", "..\\Editor\\images\\Stickers\\index.html");
//YZ 3/4/17 - adding decodeURIComponent in case URL of image saved as url formatted (for example if passing through proxy in IOS like /proxy?url=http%3A%2F%2Fwww.greetingsisland.com%2Fimages%2Fnew_editor%2Fstickers%2FBirthday%2FBirthday024.svg)
if (stickerSrc != null && decodeURIComponent(stickerSrc).indexOf('..\\images\\new_editor\\stickers\\index.html') >= 0)
stickerSrc = decodeURIComponent(stickerSrc).replace("..\\images\\new_editor\\stickers\\index.html", "..\\Editor\\images\\Stickers\\index.html");
var stickerContainer;
//YZ 1/1/19 - for custom sticker (uploaded image) - 1st convert to base64, due to CORS issues & to have the same logic as 'add a photo' images
//YZ 17/3/19 - checking the filetype and calling the different imgToBase64 method for png - to preserve png transperancy
if (stickerSrc.toLowerCase().indexOf('stickers') < 0) {
async_create_and_load_image(stickerSrc, function (savedImage) {
var filenameExtensionIsPng = savedImage.src.toLowerCase().indexOf('.png\\.png') >= 1;
var stickerSrc = filenameExtensionIsPng ? imgToBase64_png(savedImage) : imgToBase64(savedImage);
stickerContainer = thisController.place_sticker_on_designer(stickerSrc, jqFrame, stickerElement.left, stickerElement.top, true);
stickerContainer.css({
left: stickerElement.left,
top: stickerElement.top,
height: hei, //this.height,
width: stickerElement.width,
'z-index': stickerElement.zIndex,
visibility: 'visible'
});
});
}
else {
stickerContainer = thisController.place_sticker_on_designer(stickerSrc, jqFrame, stickerElement.left, stickerElement.top, true);
stickerContainer.css({
left: stickerElement.left,
top: stickerElement.top,
height: hei, //this.height,
width: stickerElement.width,
'z-index': stickerElement.zIndex,
visibility: 'visible'
});
}
});
//add (or set) texts:
console.log('LOAD_FROM_JSON - texts');
$(pageJson.textElements).each(function () {
var jsonText = this;
console.log('loadFromJSON textElement', jsonText, isFirstPage);
var jqTextSlot;
if (!isFirstPage) {
//custom textarea, exists in DOM and needs updating
jqTextSlot = jqFrame.find('.slot_text:eq(' + jsonText.indexInPage + ')');
jqTextSlot.find('textarea').val(jsonText.text)
.css({
'text-align': jsonText.textAlign,
'color': jsonText.color,
//DZ 21sep15: adding font fixing:
//'font-family': jsonText.fontFamily,
'font-family': getFontName(jsonText.fontFamily),
'font-size': jsonText.fontSize,
'line-height': lineHeightMultiplier(jsonText.fontSize.replace('px', ''), getFontName(jsonText.fontFamily)) + 'px'
});
}
else {
//DZ 2feb15: almost duplicate code was in $('#btn_add_text').click(), $(page_first.fields).each(function () { handling
//freetext (in first page or invitation) - need to add new container:
var newTextSlot = $('#template_slot_text_freesize').clone().removeAttr('id').removeClass('invis');
jqTextSlot = newTextSlot;
//newTextSlot.attr('entity_id', thisField.id);
if (!should_have_move_handle_on_freesize_text_slots)
newTextSlot.find('.move_handle').remove();
if (!should_have_trash_handle_on_freesize_text_slots)
newTextSlot.find('.delete_handle').remove();
newTextSlot.css({
left: jsonText.left,
top: jsonText.top,
'margin-left': jsonText.marginLeft,
});
newTextSlot.find('textarea')
//.val(thisField.text.replace('~~', '\n').replace('~', '\n'))
.val(jsonText.text)
.attr('placeholder', ' ')
.css({
'text-align': jsonText.textAlign,
'color': jsonText.color,
//DZ 21sep15: adding font fixing:
//'font-family': jsonText.fontFamily,
'font-family': getFontName(jsonText.fontFamily),
'font-size': jsonText.fontSize,
'line-height': lineHeightMultiplier(jsonText.fontSize.replace('px', ''), getFontName(jsonText.fontFamily)) + 'px'
});
debug.log(lineHeightMultiplier(jsonText.fontSize.replace('px', ''), getFontName(jsonText.fontFamily)) + 'px');
//DZ 11jan17: REDESIGN
//newTextSlot.css('outline-color', get_outline_color(jsonText.color));
desLogic.setColorToJQTextSlot(newTextSlot, jsonText.color);
//add to editor:
$('.editorFrame:first').append(newTextSlot);
if (jsonText.rotation && jsonText.rotation != 0) {
newTextSlot.css({
'-ms-transform': 'rotate(' + jsonText.rotation + 'deg)', /* IE 9 */
'-webkit-transform': 'rotate(' + jsonText.rotation + 'deg)', /* Chrome, Safari, Opera */
'transform': 'rotate(' + jsonText.rotation + 'deg)'
});
}
newTextSlot.find('textarea').focus(function (e) {
if (!inMobileMode)
uxController.text_design_popup_open($(e.currentTarget));
});
freesize_init(newTextSlot.find('textarea'));
make_text_slot_draggable(newTextSlot);
}
});
//now all sync stuff are done, now need to handle async photos (filters, etc)
//when we'll be finished with the async mode, we'll recursively call with idx+1
var recursive_user_image_handler = function (photoIdx) {
//END CONDITION:
if (photoIdx >= pageJson.photoElements.length) {
//call next page:
console.log('recursive_user_image_handler - end cond');
recursive_page_handler(pageIdx + 1, pageSuccFunc);
}
else {
console.log('recursive_user_image_handler', photoIdx + '..\\index.html' + pageJson.photoElements.length);
//handle photo and call next photo:
var thisUserPhoto = pageJson.photoElements[photoIdx];
debug.log('loading photoelement', thisUserPhoto);
//indexInPage - zero based
var relevantContextSlot = jqFrame.find('.slot_photo:eq(' + thisUserPhoto.indexInPage + ')');
desLogic.context_slot_photo = relevantContextSlot;
//DZ 22jun15: no more placing url as image SRC. only base64 images.
//done after caused million of issues in Safari with CORS
async_create_and_load_image(thisUserPhoto.src, function (savedImage) {
if (savedImage === null) {
//if image failed to load (missing image probably)
debug.error("Saved image failed to load. skipping");
//recursive call next:
recursive_user_image_handler(photoIdx + 1);
}
else {
var b64img = imgToBase64(savedImage);
//thisController.add_image_to_context_slot_image(thisUserPhoto.src, function () {
thisController.add_image_to_context_slot_image(b64img, function () {
//frame:
if (thisUserPhoto.frameName && thisUserPhoto.frameName.trim() != '') {
debug.log('binding frame');
desLogic.render_frame_on_context_slot_photo(thisUserPhoto.frameName);
}
//panzoom:
desLogic.context_slot_photo.find('.photo_holder img').panzoom('setMatrix', thisUserPhoto.matrix);
if (thisUserPhoto.filterName && thisUserPhoto.filterName != '' && thisUserPhoto.filterName != 'no-filter') {
//has filter
debug.log('rending filter', thisUserPhoto.filterName);
desLogic.render_filter_on_context_slot_photo(thisUserPhoto.filterName, function () {
//call next:
recursive_user_image_handler(photoIdx + 1);
});
}
else {
// no filter - call next
recursive_user_image_handler(photoIdx + 1);
}
});
}
});
}
};
//handling images: this wll call next page recursively when done with images
console.log('LOAD_FROM_JSON - images');
recursive_user_image_handler(0);
}
};
//DZ 20aug15: using previous 'forceVisible' mode to ensure all sizes are accessible for calculations
$('.editorTab').addClass('forceVisible');
recursive_page_handler(0, function () {
//after finished all pages:
console.log('recursive_page_handler - DONE, running loadSucc');
//DZ 20aug15: using previous 'forceVisible' mode to ensure all sizes are accessible for calculations
$('.editorTab').removeClass('forceVisible');
//after flipping through all card pages, going back to first tab:
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards')
// desLogic.change_editor_tab('inside');
//else
desLogic.change_editor_tab('front');
loadSuccFunc();
});
};
//PRIVATE - every sticker_container inited with this method - for draggability & resizability
function init_sticker_containers(stickerContainers) {
//resizable stamps:
stickerContainers.resizable({
//stickerContainers.find('.sticker_container_inner').resizable({
//animate: true,
aspectRatio: true,
//containment: "parent",
..\\http\\dz 9may17 mobile ghost fails to work well, nw,ne handles fail \\ghost true, \\handles\\MS_7804.html "nw,ne,se",
handles: inMobileMode ? "se" : "nw,ne,se",
..\\http\\resize function (event, ui\\MS_7805.html) {
// var zoomScale = desLogic.editor_scale;
// ui.size.width /= zoomScale;
// ui.size.height /= zoomScale;
// //console.log('da', ui);
// //also bad behavior when not resizing from bottom-right.
//}
//DZ 9may17: new method - working when disabling ghost
resize: function (event, ui) {
var zoomScale = desLogic.editor_scale;
var changeWidth = ui.size.width - ui.originalSize.width; // find change in width
var newWidth = ui.originalSize.width + changeWidth / zoomScale; // adjust new width by our zoomScale
var changeHeight = ui.size.height - ui.originalSize.height; // find change in height
var newHeight = ui.originalSize.height + changeHeight / zoomScale; // adjust new height by our zoomScale
ui.size.width = newWidth;
ui.size.height = newHeight;
}
});
//draggale stamps:
//DZ 5apr17: desktop working great. mobile needs figuring out. splitting here:
if (inMobileMode) {
stickerContainers.draggable({
//stack: true, //stack not working on IE. implemented own solution
addClasses: false, //this should improve performance (?)
cursor: "move",
opacity: 0.35,
//DZ 9may17: revert causing much issues in mobile
//revert: "invalid",
revertDuration: 250,
//scroll: true,
//DZ 9may17: no more helper/clone,appendTo used - causes unworkable issues with drag position in mobile
//helper: 'clone',
//appendTo: 'body',
//DZ 3sep14: removing overflow hotfix. many changes here and in $(".editorFrame").droppable from this date - revert from SVN
start: function () {
//makes sure dragged element has max zIndex
thisController.bring_sticker_to_front($(this));
//DZ 4apr17 - redmob - based on textSlot draggable fix
lastDragStartPos.x = event.clientX;
lastDragStartPos.y = event.clientY;
//$(this).parents('.editorFrame').css('overflow', 'visible');
//console.log('drag startted');
//we show overflow (for stickers) only for mobile mode, for 'inner' card states
//DZ 11sep17: adding ecards v2 support:
//var inMiddleCardTab = (editorMode == 'ecards' || (editorMode == 'cards' && $('.tabInside.active').length > 0));
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//var inMiddleCardTab = (editorMode == 'ecards' || ((editorMode == "ecards_v2" ||editorMode == 'cards') && $('.tabInside.active').length > 0));
var inMiddleCardTab = ((editorMode == "ecards" || editorMode == 'cards') && $('.tabInside.active').length > 0);
if (inMobileMode && inMiddleCardTab)
$('.editorFrame').css('overflow', 'visible');
},
drag: function (event, ui) {
//DZ 4apr17: re DZ27mar17: for fixing dragging in scaled divs (see http://stackoverflow.com/questions/13882070/jquery-draggable-and-webkit-transform-scale)
//scaling fixes:
var zoom = desLogic.editor_scale;
var original = ui.originalPosition;
ui.position = {
left: (event.clientX - lastDragStartPos.x + original.left) / zoom,
top: (event.clientY - lastDragStartPos.y + original.top) / zoom
};
//because we use the 'clone' option (to allow moving of sticker between card's inner pages), we must update the clone's position too:
//var helper = $(".selector").draggable("option", "helper");
//console.log('hhh', helper);
//helper.css({
// left: (event.clientX - lastDragStartPos.x + original.left) / zoom,
// top: (event.clientY - lastDragStartPos.y + original.top) / zoom
//});
//console.log(zoom, original, ui);
},
stop: function (event, ui) {
//console.log('drag stoppedd', ui, $(this));
//we show overflow (for stickers) only for mobile mode, for 'inner' card states
var originalSticker = $(ui.helper.context);
//DZ 11sep17: adding ecards v2 support:
//var inMiddleCardTab = (editorMode == 'ecards' || (editorMode == 'cards' && $('.tabInside.active').length > 0));
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//var inMiddleCardTab = (editorMode == 'ecards' || ((editorMode == "ecards_v2" || editorMode == 'cards') && $('.tabInside.active').length > 0));
var inMiddleCardTab = ((editorMode == "ecards" || editorMode == 'cards') && $('.tabInside.active').length > 0);
//if (inMobileMode && $('.tabInside.active').length > 0) {
if (inMobileMode && inMiddleCardTab) {
$('.editorFrame').css('overflow', 'hidden');
//sometimes (ME-49) targetFrame is detected as originalFrame, but indeed it exceeds to the other card. here we detect these cases
//trying to detected dragging between frames. if so, we will removed 'old' sticker and create a new one in the right place
//(mobile only)
var originalFrame = originalSticker.parents('.editorFrame');
var originalFrameIsFirstChild = originalFrame.is(':first-child');
var needsToBeMovedBetweenFrames = false;
var newLeft = ui.position.left;
var newTop = ui.position.top;
if (getLayout() != 'landscape') {
//SQUARE AND PORTRAIT LAYOUTS:
var containerWidth = originalFrame.width();
var halfStickerWidth = originalSticker.width() / 2;
if (originalFrameIsFirstChild && ui.position.left > containerWidth - halfStickerWidth) {
//moved from left to right
needsToBeMovedBetweenFrames = true;
newLeft = ui.position.left - containerWidth;
}
else if (!originalFrameIsFirstChild && ui.position.left < 0 - halfStickerWidth) {
//moved from right to left
needsToBeMovedBetweenFrames = true;
newLeft = ui.position.left + containerWidth;
}
}
else {
//LANDSCAPE LAYOUT:
var containerHeight = originalFrame.height();
var halfStickerHeight = originalSticker.height() / 2;
if (originalFrameIsFirstChild && ui.position.top > containerHeight - halfStickerHeight) {
//moved from top to bottom
needsToBeMovedBetweenFrames = true;
newTop = ui.position.top - containerHeight;
}
else if (!originalFrameIsFirstChild && ui.position.top < 0 - halfStickerHeight) {
//moved from bottom to top
needsToBeMovedBetweenFrames = true;
newTop = ui.position.top + containerHeight;
}
}
if (needsToBeMovedBetweenFrames) {
console.log("MOVING STICKER BETWEEN FRAMES - drag() event");
var targetFrame = originalFrameIsFirstChild ? $('.tabInside .editorFrame:last-child') : $('.tabInside .editorFrame:first-child');
var newSticker = originalSticker.clone();
newSticker.removeClass('ui-resizable').css('opacity', 'inherit');
newSticker.find('.ui-resizable-handle').remove();
$('body').css('cursor', 'inherit');
newSticker.css({ left: newLeft, top: newTop });
originalSticker.remove();
targetFrame.append(newSticker);
init_sticker_containers(newSticker);
desLogic.reposition_sticky_handles(newSticker);
}
}
setTimeout(function () {
desLogic.reposition_sticky_handles(originalSticker);
}, 50);
}
});
}
else {
//desktop mode - much simpler
stickerContainers.draggable({
//stack: true, //stack not working on IE. implemented own solution
addClasses: false, //this should improve performance (?)
cursor: "move",
opacity: 0.35,
revert: "invalid",
revertDuration: 250,
scroll: true,
helper: 'clone',
appendTo: 'body',
//DZ 3sep14: removing overflow hotfix. many changes here and in $(".editorFrame").droppable from this date - revert from SVN
start: function () {
//makes sure dragged element has max zIndex
thisController.bring_sticker_to_front($(this));
}
});
}
}
//PUBLIC
this.place_sticker_on_designer = function (url, frameContainer, x, y, skipProportionsFix) {
desLogic.mark_as_dirty();
var stickerContainer = $('#template_sticker_container').clone().removeAttr('id')
.css({ left: x, top: y, visibility: 'hidden' });
//DZ 13jun14: safari security hotfix
//stickerContainer.find('.sticker_container_inner').append($('
![]()
').attr('src', url));
//url starts with /images/
var fixed_url = url;
//getParameterByName('force_proxy') condition - only for testing
//DZ 11mar18: SAM code merge:
//DZ 5dec17 (SAM) not required for SAM
//if (sayswho().indexOf('Safari') > -1 || getParameterByName('force_proxy') != '') {
//DZ 29jul18: not applying safari proxy fix for custom stickers [CIE-283]
var isBase64 = url.length > 50 && url.substring(0, 49).indexOf(';base64') > 0;
if (editorAppMode !== "SAM" && !isBase64 && (sayswho().indexOf('Safari') > -1 || getParameterByName('force_proxy') != '')) {
debug.log('fixing url for safari');
if (url.indexOf('..\\index.html') == 0)
//DZ 29jul18: previous, normal fix for saved stickers that start with relative URL, e.g. /images/stickers/etc...
fixed_url = "..\\MS_59.html?url=" + encodeURIComponent("http\\MS_24.html" + document.location.host + url);
else
//DZ 29jul18: new fix for saved stickers. with abs. URL
fixed_url = "..\\MS_59.html?url=" + encodeURIComponent(url);
}
stickerContainer.find('.sticker_container_inner').append($('
![]()
').attr('src', fixed_url));
frameContainer.append(stickerContainer);
//DZ 27aug14: fixing IE9 bug. sometimes, some stickers (e.g. Animals/Animals002.svg) get unneeded attributes width,height
stickerContainer.find('.sticker_container_inner img').removeAttr('width').removeAttr('height');
init_sticker_containers(stickerContainer);
//makes sure dragged element has max zIndex
thisController.bring_sticker_to_front(stickerContainer);
//DZ 14sep14: making sure sticker not too muc hhigh
if (!skipProportionsFix)
async_create_and_load_image(fixed_url, function (img) {
var maxHeight = 150;
var h = stickerContainer.height();
if (h > maxHeight) {
debug.log('sticker height too high. fixing width accordingly');
var w = stickerContainer.width();
var ratio = w / h;
var targetWidth = maxHeight * ratio;
stickerContainer.css({
'width': targetWidth + 'px',
'left': parseInt(x) + ((w - targetWidth) / 2)
});
}
stickerContainer.css('visibility', 'visible');
});
//DZ 2feb15: added return value for load customization
return stickerContainer;
}
//PUBLIC
this.add_image_to_context_slot_image = function (imgSrc, succFunc) {
desLogic.mark_as_dirty();
//only for local testing
if (getParameterByName('force_proxy') != '' && imgSrc.indexOf("http\\MS_24.html") >= 0) {
imgSrc = "..\\MS_59.html?url=" + encodeURIComponent(imgSrc);
debug.warn("temp s3 subdomin fix", imgSrc);
}
async_create_and_load_image(imgSrc, function (img) {
//DZ 22jan15: in case that it wasnt an image file (e.g. txt)
if (img == null) {
if (succFunc) {
succFunc();
setTimeout(function () {
if (!inMobileMode) {
uxController.bind_simple_popup("popup_with_close_btn", "Error", "Invalid Image File Uploaded.\nPlease try again.", "Close");
uxController.show_popup_centered($('#popup_simple_template'));
}
}, 100);
}
}
else {
var finish_func = function (finalImgObj) {
//END CONDITION:
desLogic.context_slot_photo.find('.photo_holder').empty().append(finalImgObj);
desLogic.context_slot_photo.addClass('has_photo');
var contextImg = $(finalImgObj); //desLogic.context_slot_photo.find('img');
thisController.init_image_size_in_box_container(contextImg);
//allows zooming and panning
thisController.panzoom_init_image(contextImg);
if (succFunc)
succFunc();
}
//YZ11oct: changing max width to 2250
//DZ 5nov15: making it dynamic, according to number of images in invitation
var MAX_WIDTH = 1500;
//if setting from parameter
if (getParameterByName('iwidth') !== '')
MAX_WIDTH = Number(getParameterByName('iwidth'));
//invitations with 1 photo slot
else if (editorMode == 'invitations' && $('.editorTab .slot_photo').length == 1)
MAX_WIDTH = 2250;
//DZ 21oct15: adding limits to height as well (used to be only width)
if (img.width > img.height && img.width > MAX_WIDTH) {
//width exceeds
debug.log("rescaling img due to width=" + img.width);
resize_img(imgSrc, MAX_WIDTH, finish_func);
}
else if (img.height >= img.width && img.height > MAX_WIDTH) {
//height exceeds
//var new_height = MAX_WIDTH;
var new_width = (img.width / img.height) * MAX_WIDTH;
debug.log("rescaling img due to height. new width=" + new_width);
resize_img(imgSrc, new_width, finish_func);
}
//DZ 11nov15: hotfix for un-compressed images on iOS - they have EXIF data which messed up our canvas / html drawing (CIE-81 - On ipad - uploaded images get 90 degrees rotated when exported)
else if (isIOS()) {
//just cloning the image to same width
debug.log("iOS fix: cloning/rescaling img to same width . new width=" + img.width);
resize_img(imgSrc, img.width, finish_func);
}
else {
// //no need to compress:
finish_func(img);
}
}
});
}
//---------- images / upload ------------
this.init_image_size_in_box_container = function (jqImgElm) {
//this method receives an img, and sets either height or width to 100% so it will fill container.
//setting img css to be free, so we can salvage img width/height
jqImgElm.css({ width: 'auto', height: 'auto' });
var slotDiv = jqImgElm.parents('.slot_photo');
var boxRatio = slotDiv.width() / slotDiv.height();
var imgRatio = jqImgElm.width() / jqImgElm.height();
//DZ 10jun14: added 'auto' to fix IE giving absolute width,height & distorting image
//debug.log('boxRatio=' + boxRatio + ' imgRatio=' + imgRatio);
if (boxRatio < imgRatio) {
debug.log('100% height image in slot');
jqImgElm.css({ height: '100%', width: 'auto' });
}
else {
debug.log('100% width image in slot');
jqImgElm.css({ width: '100%', height: 'auto' });
}
};
//public
this.panzoom_init_image = function (jqImgElm) {
//debug.log('panzoom_init_image', jqImgElm);
jqImgElm.panzoom('destroy');
jqImgElm.panzoom({
contain: 'invert',
minScale: 1,
maxScale: 10,
//not working: panzoomzoom: thisController.pan_zoom_zoom_handler,
//not working: panzoomend: function (e, panzoom, x, y) { debug.log('pan event'); e.preventDefault(); }
});
//for mobile zooming - updates the popup's slider
jqImgElm.on('panzoomzoom', thisController.pan_zoom_zoom_handler);
//disables 'click' event after dragging:
jqImgElm.on('panzoomend', function (e, panzoom, matrix, changed) { if (changed) markDragEnd(); });
//jqImgElm.on('mouseup', function (e, panzoom, x, y) { debug.log('pan event2'); e.stopPropagation(); })
};
//invoked when zoom (manually by has changed. updates the slider (if open)
this.pan_zoom_zoom_handler = function (e, panzoom, x, y) {
//for desktop:
if ((!inMobileMode && $('#popup_image_style').is(':visible')) || (inMobileMode && $('#slider_image_zoom:visible').length > 0))
$('#slider_image_zoom').slider({ value: x });
};
//PUBLIC
//max z-index of sticker in frame
this.bring_sticker_to_front = function (stickerContainer) {
var maxZindex = 0;
stickerContainer.parents('.editorFrame').find('.sticker_container').each(function () {
var thisZIndex = parseInt($(this).css('z-index'));
if (thisZIndex > maxZindex)
maxZindex = thisZIndex;
});
stickerContainer.css('z-index', maxZindex + 1);
}
//PUBLIC
//DZ 1jan15: NEWER IFRAME HOTFIX:
//DZ 16jul14: NEW IFRAME HOTFIX:
this.render_filter_on_context_slot_photo = function (filter_name, filterSuccFunc) {
//DZ 7feb17: removing (temporarlily?) loading for Nataly to view
//now_loading_start();
//DZ 28dec14: making sure inner iframe is inited:
var innerRecursiveFunc = function (num_of_tries_left) {
if (num_of_tries_left > 0) {
var innerIframe = $('#iframe_filter_helper');
if (innerIframe.length == 0 || innerIframe[0].contentWindow == null || typeof innerIframe[0].contentWindow.render_filter_on_img === "undefined") {
debug.log("inner filter frame still not ready - " + num_of_tries_left + ' tries left');
setTimeout(function () {
innerRecursiveFunc(num_of_tries_left - 1);
}, 200);
}
else {
debug.log('rendering effect ' + filter_name);
//first, if this is the first time a filter was selected for an image, we store the original (non-altered) src of the image inside the slot tag
//this will be base src for future filters, but saved only on first call
if (desLogic.context_slot_photo.attr('unfiltered_src') == null)
desLogic.context_slot_photo.attr('unfiltered_src', desLogic.context_slot_photo.find('img').attr('src'));
//DZ 13aug14: hotfixing strange error: css(transform) changed after effect (wtf?)
var hotfixTransformCss = desLogic.context_slot_photo.find('img').css('transform');
//second, if 'no-filter' was chosen, we retrieve the image from memory:
if (filter_name == 'no-filter') {
desLogic.context_slot_photo.find('img').attr('src', desLogic.context_slot_photo.attr('unfiltered_src'));
//desLogic.context_slot_photo.find('img').css('transform', hotfixTransformCss);
//DZ 4jun17: this remained here, after 7feb17 fix for no loading animation for filters.
//now_loading_stop();
if (filterSuccFunc)
filterSuccFunc();
}
else {
var img_src = desLogic.context_slot_photo.attr('unfiltered_src');//desLogic.context_slot_photo.find('img').attr('src');
innerIframe[0].contentWindow.render_filter_on_img(img_src, filter_name, function (newImageData) {
debug.log('filterred image returned');
desLogic.context_slot_photo.find('img').attr('src', newImageData);
//DZ 9mar15: adding succFunc for load scenario
if (filterSuccFunc)
filterSuccFunc();
//DZ 4jun17: this remained here, after 7feb17 fix for no loading animation for filters.
//now_loading_stop();
var t = $('#iframe_filter_helper').clone();
$('#iframe_filter_helper').remove();
$('body').append(t);
});
}
//so we'll know current filter (for revert scenario if opened again);
desLogic.context_slot_photo.attr('filter_name', filter_name);
}
}
};
innerRecursiveFunc(20);
};
//FRAME SET:
this.render_frame_on_context_slot_photo = function (frame_name) {
debug.log('frame_name', frame_name);
thisController.bind_frame_to_slot_photo(desLogic.context_slot_photo, frame_name);
};
this.bind_frame_to_slot_photo = function (slot_photo, frame_name) {
slot_photo.find('.slot_frame_shape_layer,.slot_frame_corner,.slot_frame_line').remove();
//slot_photo.find('.slot_frame_corner').remove();
slot_photo.attr('current_frame', frame_name);
if (frame_name != 'none') {
//corner OR shape
if (frame_name.indexOf('corner_') >= 0) {
//create 4 corners
var c1 = $('
').css({ top: '5px', left: '5px', 'background-image': 'url(\\Editor\\Images\\frames\\index.html' + frame_name + '_lt.png)' });
var c2 = $('
').css({ top: '5px', right: '5px', 'background-image': 'url(\\Editor\\Images\\frames\\index.html' + frame_name + '_rt.png)' });
var c3 = $('
').css({ bottom: '5px', left: '5px', 'background-image': 'url(\\Editor\\Images\\frames\\index.html' + frame_name + '_lb.png)' });
var c4 = $('
').css({ bottom: '5px', right: '5px', 'background-image': 'url(\\Editor\\Images\\frames\\index.html' + frame_name + '_rb.png)' });
var l1 = $('
').css({ height: '5px', width: '100%', top: 0, left: 0 });
var l2 = $('
').css({ height: '5px', width: '100%', bottom: 0, left: 0 });
var l3 = $('
').css({ width: '5px', height: '100%', top: 0, left: 0 });
var l4 = $('
').css({ width: '5px', height: '100%', top: 0, right: 0 });
slot_photo.append(c1).append(c2).append(c3).append(c4)
.append(l1).append(l2).append(l3).append(l4);
}
else {
//we check if container is WIDE or TALL, so we can put the right frame to cover the entire thing on width OR height = 100%
var isTall = slot_photo.height() > slot_photo.width();
debug.log('istall=' + isTall);
var bg_filename = "..\\Editor\\Images\\frames\\index.html" + frame_name + "_" + (isTall ? 'tall' : 'wide') + ".png\\.png";
var frameDiv = $('
').addClass('slot_frame_shape_layer').css({ 'background-image': 'url(' + bg_filename + ')' });
slot_photo.append(frameDiv);
}
}
}
//public
this.change_text_slot_font = function (jqTextSlot, fontName) {
//DZ 28jul14: adding position fix after font-change
var old_width = jqTextSlot.width();
var jqTextArea = jqTextSlot.find('textarea');
jqTextArea.css({
'font-family': getFontName(fontName),
'line-height': lineHeightMultiplier(parseFloat(jqTextArea.css('font-size').replace('px', '')), getFontName(fontName)) + 'px'
}); //.trigger('autosize.resize');;
//DZ 24sep15: fixing CIE-14 - After max zooming and clicking Cancel text from the bottom part of invitation disappears
desLogic.reinit_autosizer(jqTextArea);
jqTextArea.trigger('keyup');
if (jqTextSlot.hasClass('freesize')) {
var oldLeft = parseFloat(jqTextSlot.css('left').replace('px'));
thisController.update_text_slot_after_change(jqTextSlot, jqTextArea, old_width, oldLeft);
}
};
//public - we're calling this method after we do a change that requires slight alignment reposition
//example: after changing font, or after changing text (mobile only) - we need to persist location according to text-align (see also issue ME-18)
this.update_text_slot_after_change = function (jqTextSlot, jqTextArea, old_width, oldLeft) {
var new_width = jqTextSlot.width();
var width_diff = new_width - old_width;
//var oldLeft = parseFloat(jqTextSlot.css('left').replace('px'));
var newLeft = oldLeft;
if (jqTextArea.css('text-align').toLowerCase() == 'center')
newLeft = (oldLeft - (width_diff / 2));
else if (jqTextArea.css('text-align').toLowerCase() == 'right')
newLeft = oldLeft - width_diff;
if (oldLeft != newLeft)
jqTextSlot.css('left', newLeft + 'px');
};
//private - init fonts, according to sprite
function bindFontSelection() {
//using sprite, and 'sid' from view
//DZ 11mar18 (FONT-POS): moving to here, used to be in bind_drawers
if (inMobileMode) {
//DZ 11mar18: moved from here, to be just before applying events:
//DZ 27mar17: moving shard fonts HTML to its right position
//clone,remove,and re-position (reason: shared HTML, should be in right place in desktop / mobile)
var cloned = $('#editor-fonts').clone();
$('#editor-fonts').remove();
//new class for mobile design, removing some extra styling from desktop version
cloned.addClass("fonts-list").css({
'display': 'inherit',
'position': 'inherit'
});
$('#edit-font-name').append(cloned);
console.log('----------- DEBUG - CLONED NOW');
}
var ITEM_HEIGHT = 30;
var sheet = window.document.styleSheets[0]
//$('#popup_text_style .custom_scroll li span').each(function () {
$('#editor-fonts li span').each(function () {
var fontSpan = $(this);
var sidx = parseInt(fontSpan.attr('sid'));
//console.log("PROCSSING", sidx, 'url(\\images\\new_editor\\sprite_fonts.png) no-repeat 0 -' + (ITEM_HEIGHT * sidx) + 'px');
//DZ 6feb17: new sprite, with 'hover' state
//DZ 11mar18: SAM code merge
//fontSpan.css({ background: 'url(\\Editor\\images\\MS_7806.html) no-repeat 0 ' + (-(ITEM_HEIGHT * sidx)) + 'px' }).css({ 'background-size': '340px 1380px' });
if (editorAppMode !== "SAM")
fontSpan.css({ background: 'url(\\Editor\\images\\sprite_fonts.png) no-repeat 0 ' + (-(ITEM_HEIGHT * sidx)) + 'px' }).css({ 'background-size': '340px 1380px' });
else
fontSpan.css({ background: 'url(images\\sprite_fonts.png) no-repeat 0 ' + (-(ITEM_HEIGHT * sidx)) + 'px' }).css({ 'background-size': '340px 1380px' });
});
//$('#popup_text_style .options li').click(function () {
$('#editor-fonts li').click(function () {
console.log("DEBUG - inside click event")
var newVal = getFontName($(this).find('span').css('font-family'));
var fontSize = $(this).find('span').css('font-size'); //YZ 19-12-16: getting the font size to later assign to the 'selected' span
//DZ 1dec16: making sure font is loaded
var fontArray = new Array();
fontArray.push(newVal);
var currentFontText = $(this).text();
desLogic.loadFonts(fontArray, function () {
//DZ 28jul14: adding position fix after font-change
desLogic.change_text_slot_font(desLogic.text_design_popup_current_target.parents('.slot_text'), newVal);
if (!inMobileMode) {
$('#popup_text_style .selected p').empty();
$('#popup_text_style .selected p').append($('
'));
$('#popup_text_style .selected p span').text(currentFontText);
$('#popup_text_style .selected p span').css('font-family', newVal).css('font-size', fontSize); //YZ 19-12-16: assign font-size to the 'selected' span
}
//DZ 24sep17: was missing!
desLogic.mark_as_dirty();
});
//DZ 12jan17: adding 'selected' style to font list-item:
$('#editor-fonts li.active').removeClass('active');
$(this).addClass('active');
//var fontSpanSelector = '#editor-fonts li #span_font_sel_' + strreplace(newVal.toLowerCase(), "'", "");
//$(fontSpanSelector).parent().addClass('active');
});
//console.log('----------- DEBUG - APPLIED EVENT NOW', $('#editor-fonts li').length);
}
//public
this.add_new_text_slot = function () {
desLogic.mark_as_dirty();
//=== NOTICE: ALMOST DUPLICATE CODE in bind_card_metadata()
var newTextSlot = $('#template_slot_text_freesize').clone().removeAttr('id').removeClass('invis');
if (!should_have_move_handle_on_freesize_text_slots)
newTextSlot.find('.move_handle').remove();
if (!should_have_trash_handle_on_freesize_text_slots)
newTextSlot.find('.delete_handle').remove();
var default_color = '#000000';
//just for new texts:
newTextSlot.find('textarea').css({
'text-align': 'center',
'color': default_color,
'font-family': 'arimoregular',
'font-size': '20px',
'line-height': lineHeightMultiplier(20, 'arimoregular') + 'px'
});
//add to editor:
//default (portfolio card) locations:
var newSlotTop = 245;
var newSlotLeft = 180;
var current_layout = getLayout();
switch (current_layout) {
case "square":
newSlotTop = 248;
newSlotLeft = 285;
break;
case "landscape":
newSlotTop = 150;
newSlotLeft = 275;
break;
}
newTextSlot.css({
top: newSlotTop + 'px',
left: newSlotLeft + 'px'
http\\MS_24.html'outline-color': get_outline_color(default_color)
});
//DZ 11jan17: REDESIGN
desLogic.setColorToJQTextSlot(newTextSlot, default_color);
$('.editorFrame:first').append(newTextSlot);
//NOTICE: autogrow() is different than autosize()! different plugins!
freesize_init(newTextSlot.find('textarea'));
make_text_slot_draggable(newTextSlot);
//DZ 28sep14: added this hotfix, like in original:
//DZ 9jul14: hotfix: in IE (IE11 tested) some other jquery fixes 'placeholder' textareas to have value of placeholder. hotfixing here:
//newTextSlot.find('textarea[placeholder]').each(function () {
// var jqTextarea = $(this);
// var phText = jqTextarea.attr('placeholder');
// if (phText == jqTextarea.val())
// jqTextarea.val('');
//});
//DZ 28sep14: added condition, like in original
//if (isIE9)
// //DZ 27aug14:
// fix_ie9_placeholders(newTextSlot);
desLogic.set_focus(newTextSlot);
if (inMobileMode) {
//newTextSlot.click();
//for mobile, we create the textslot above, and then mark it as "on hold", launch the 'edit text' modal, and cancel the new text if its cancelled
uxController.openTextDrawer(newTextSlot.find('textarea'));
newTextSlot.attr('on-hold-text', 1);
uxController.open_text_edit_modal();
}
else {
//desktop
newTextSlot.find('textarea').focus(function (e) {
uxController.text_design_popup_open($(e.currentTarget));
});
newTextSlot.find('textarea').focus();
}
}
/* -------------------- STICKERS ------------------ */
function bind_stickers() {
var stickers_black_list = new Array();
//DZ 20sep15: [CIE-67] prepare a blacklist of stickers to remove from designer
//Add black listed stickers here:
stickers_black_list = [
'Animals/Animals000.svg',
'Animals/Animals001.svg',
'Animals/Animals002.svg',
'Animals/Animals003.svg',
'Animals/Animals004.svg',
'Animals/Animals005.svg',
'Animals/Animals006.svg',
'Animals/Animals011.svg',
'Animals/Animals012.svg',
'Animals/Animals013.svg',
'Animals/Animals016.svg',
'Animals/Animals017.svg',
'Animals/Animals018.svg',
'Animals/Animals019.svg',
'Animals/Animals020.svg',
'Animals/Animals021.svg',
'Animals/Animals022.svg',
'Animals/Animals023.svg',
'Animals/Animals024.svg',
'Animals/Animals027.svg',
'Animals/Animals030.svg',
'Animals/Animals031.svg',
'Animals/Animals032.svg',
'Animals/Animals033.svg',
'Animals/Animals034.svg',
'Animals/Animals035.svg',
'Animals/Animals036.svg',
'Animals/Animals037.svg',
'Animals/Animals038.svg',
'Animals/Animals041.svg',
'Animals/Animals042.svg',
'Animals/Animals043.svg',
'Animals/Animals048.svg',
'Animals/Animals049.svg',
'Animals/Animals050.svg',
'Animals/Animals051.svg',
'Animals/Animals052.svg',
'Animals/Animals059.svg',
'Animals/Animals060.svg',
'Animals/Animals061.svg',
'Animals/Animals062.svg',
'Animals/Animals063.svg',
'Animals/Animals064.svg',
'Animals/Animals065.svg',
'Animals/Animals066.svg',
'Animals/Animals067.svg',
'Animals/Animals068.svg',
'Animals/Animals069.svg',
'Animals/Animals071.svg',
'Animals/Animals072.svg',
'Animals/Animals074.svg',
'Animals/Animals075.svg',
'Animals/Animals076.svg',
'Animals/Animals078.svg',
'Animals/Animals079.svg',
'Animals/Animals080.svg',
'Animals/Animals082.svg',
'Floral/Floral092.svg',
'Floral/Floral000.svg',
'Floral/Floral001.svg',
'Floral/Floral002.svg',
'Floral/Floral003.svg',
'Floral/Floral004.svg',
'Floral/Floral005.svg',
'Floral/Floral009.svg',
'Floral/Floral010.svg',
'Floral/Floral014.svg',
'Floral/Floral015.svg',
'Floral/Floral016.svg',
'Floral/Floral017.svg',
'Floral/Floral018.svg',
'Floral/Floral030.svg',
'Floral/Floral041.svg',
'Floral/Floral042.svg',
'Floral/Floral044.svg',
'Floral/Floral045.svg',
'Floral/Floral046.svg',
'Floral/Floral047.svg',
'Floral/Floral048.svg',
'Floral/Floral049.svg',
'Floral/Floral070.svg',
'Floral/Floral082.svg',
'Floral/Floral084.svg',
'Floral/Floral097.svg',
'Floral/Floral098.svg',
'Floral/Floral099.svg',
'Floral/Floral100.svg',
'Holidays/Holidays007.svg',
'Holidays/Holidays020.svg',
'Holidays/Holidays023.svg',
'Holidays/Holidays039.svg',
'Holidays/Holidays002.svg',
'Holidays/Holidays004.svg',
'Holidays/Holidays007.svg',
'Holidays/Holidays010.svg',
'Holidays/Holidays011.svg',
'Holidays/Holidays014.svg',
'Holidays/Holidays015.svg',
'Holidays/Holidays017.svg',
'Holidays/Holidays018.svg',
'Holidays/Holidays024.svg',
'Holidays/Holidays025.svg',
'Holidays/Holidays026.svg',
'Holidays/Holidays027.svg',
'Holidays/Holidays028.svg',
'Holidays/Holidays029.svg',
'Holidays/Holidays044.svg',
'Holidays/Holidays045.svg',
'Holidays/Holidays046.svg',
'Holidays/Holidays047.svg',
'Holidays/Holidays048.svg',
'Holidays/Holidays049.svg',
'Holidays/Holidays050.svg',
'Holidays/Holidays054.svg',
'Holidays/Holidays065.svg',
'Holidays/Holidays077.svg',
'Holidays/Holidays078.svg',
'Holidays/Holidays079.svg',
'Holidays/Holidays080.svg',
'Holidays/Holidays081.svg',
'Holidays/Holidays082.svg',
'Holidays/Holidays083.svg',
'Holidays/Holidays084.svg',
'Holidays/Holidays085.svg',
'Holidays/Holidays086.svg',
'Holidays/Holidays087.svg',
'Holidays/Holidays088.svg',
'Holidays/Holidays089.svg',
'Holidays/Holidays090.svg',
'Holidays/Holidays103.svg',
'Party/Party000.svg',
'Party/Party001.svg',
'Party/Party002.svg',
'Party/Party004.svg',
'Party/Party006.svg',
'Party/Party043.svg',
'Party/Party066.svg',
'Party/Party069.svg',
'Party/Party070.svg',
'Party/Party071.svg',
'Party/Party074.svg',
'Party/Party075.svg',
'Party/Party076.svg',
'Party/Party007.svg',
'Party/Party023.svg',
'Party/Party024.svg',
'Party/Party025.svg',
'Party/Party026.svg',
'Party/Party027.svg',
'Party/Party028.svg',
'Party/Party029.svg',
'Party/Party030.svg',
'Party/Party044.svg',
'Party/Party062.svg',
'Party/Party063.svg',
'Party/Party064.svg',
'Party/Party065.svg',
'Party/Party068.svg',
'Party/Party007.svg',
'Party/Party012.svg',
'Party/Party013.svg',
'Party/Party015.svg',
'Party/Party016.svg',
'Party/Party019.svg',
'Party/Party021.svg',
'Party/Party023.svg',
'Party/Party024.svg',
'Party/Party025.svg',
'Party/Party026.svg',
'Party/Party027.svg',
'Party/Party028.svg',
'Party/Party030.svg',
'Party/Party043.svg',
'Party/Party044.svg',
'Party/Party045.svg',
'Party/Party046.svg',
'Party/Party047.svg',
'Party/Party048.svg',
'Party/Party049.svg',
'Party/Party050.svg',
'Party/Party051.svg',
'Party/Party052.svg',
'Party/Party054.svg',
'Party/Party055.svg',
'Party/Party056.svg',
'Party/Party057.svg',
'Party/Party058.svg',
'Party/Party059.svg',
'Party/Party060.svg',
'Party/Party061.svg',
'Party/Party062.svg',
'Party/Party063.svg',
'Party/Party064.svg',
'Party/Party065.svg',
'Party/Party066.svg',
'Party/Party067.svg',
'Party/Party068.svg',
'Party/Party069.svg',
'Party/Party070.svg',
'Party/Party071.svg',
'Party/Party072.svg',
'Party/Party073.svg',
'Party/Party083.svg',
'Party/Party084.svg',
'Party/Party085.svg',
'Party/Party086.svg',
'Party/Party087.svg',
'Party/Party111.svg',
'Birthday/Birthday001.svg',
'Birthday/Birthday002.svg',
'Birthday/Birthday005.svg',
'Birthday/Birthday006.svg',
'Birthday/Birthday012.svg',
'Birthday/Birthday013.svg',
'Birthday/Birthday014.svg',
'Birthday/Birthday015.svg',
'Birthday/Birthday016.svg',
'Birthday/Birthday022.svg',
'Birthday/Birthday023.svg',
'Birthday/Birthday026.svg',
'Birthday/Birthday032.svg',
'Birthday/Birthday033.svg',
'Birthday/Birthday034.svg',
'Birthday/Birthday038.svg',
'Birthday/Birthday039.svg',
'Birthday/Birthday043.svg',
'Birthday/Birthday047.svg',
'Birthday/Birthday048.svg',
'Birthday/Birthday049.svg',
'Birthday/Birthday050.svg',
'Birthday/Birthday051.svg',
'Birthday/Birthday052.svg',
'Birthday/Birthday053.svg',
'Birthday/Birthday054.svg',
'Birthday/Birthday055.svg',
'Birthday/Birthday056.svg',
'Birthday/Birthday057.svg',
'Birthday/Birthday058.svg',
'Birthday/Birthday059.svg',
'Birthday/Birthday060.svg',
'Birthday/Birthday061.svg',
'Birthday/Birthday062.svg',
'Birthday/Birthday063.svg',
'Birthday/Birthday064.svg',
'Birthday/Birthday065.svg',
'Birthday/Birthday066.svg',
'Birthday/Birthday068.svg',
'Children/Children049.svg',
'Children/Children000.svg',
'Children/Children001.svg',
'Children/Children002.svg',
'Children/Children003.svg',
'Children/Children004.svg',
'Children/Children005.svg',
'Children/Children006.svg',
'Children/Children007.svg',
'Children/Children008.svg',
'Children/Children009.svg',
'Children/Children010.svg',
'Children/Children011.svg',
'Children/Children012.svg',
'Children/Children013.svg',
'Children/Children014.svg',
'Children/Children015.svg',
'Children/Children016.svg',
'Children/Children017.svg',
'Children/Children018.svg',
'Children/Children019.svg',
'Children/Children020.svg',
'Children/Children021.svg',
'Children/Children022.svg',
'Children/Children023.svg',
'Children/Children024.svg',
'Children/Children025.svg',
'Children/Children026.svg',
'Children/Children027.svg',
'Children/Children028.svg',
'Children/Children029.svg',
'Children/Children030.svg',
'Children/Children031.svg',
'Children/Children032.svg',
'Children/Children033.svg',
'Children/Children034.svg',
'Children/Children035.svg',
'Children/Children036.svg',
'Children/Children041.svg',
'Children/Children042.svg',
'Children/Children043.svg',
'Children/Children044.svg',
'Children/Children045.svg',
'Children/Children050.svg',
'Children/Children051.svg',
'Children/Children069.svg',
'Children/Children070.svg',
'Children/Children071.svg',
'Children/Children072.svg',
'Children/Children073.svg',
'Children/Children083.svg',
'Children/Children092.svg',
'Children/Children093.svg',
'Children/Children094.svg',
'Children/Children095.svg',
'Children/Children096.svg',
'Children/Children097.svg',
'Children/Children098.svg',
'Children/Children099.svg',
'Children/Children100.svg',
'Children/Children101.svg',
'Children/Children102.svg',
'Children/Children103.svg',
'Children/Children104.svg',
'Children/Children105.svg',
'Children/Children106.svg',
'Children/Children107.svg',
'Children/Children108.svg',
'Children/Children109.svg',
'Children/Children110.svg',
'Christmas/Christmas099.svg',
'Christmas/Christmas101.svg',
'Christmas/Christmas102.svg',
'Christmas/Christmas000.svg',
'Christmas/Christmas001.svg',
'Christmas/Christmas002.svg',
'Christmas/Christmas009.svg',
'Christmas/Christmas010.svg',
'Christmas/Christmas012.svg',
'Christmas/Christmas013.svg',
'Christmas/Christmas014.svg',
'Christmas/Christmas024.svg',
'Christmas/Christmas025.svg',
'Christmas/Christmas026.svg',
'Christmas/Christmas027.svg',
'Christmas/Christmas028.svg',
'Christmas/Christmas029.svg',
'Christmas/Christmas030.svg',
'Christmas/Christmas031.svg',
'Christmas/Christmas032.svg',
'Christmas/Christmas033.svg',
'Christmas/Christmas034.svg',
'Christmas/Christmas035.svg',
'Christmas/Christmas036.svg',
'Christmas/Christmas039.svg',
'Christmas/Christmas043.svg',
'Christmas/Christmas044.svg',
'Christmas/Christmas045.svg',
'Christmas/Christmas046.svg',
'Christmas/Christmas047.svg',
'Christmas/Christmas048.svg',
'Christmas/Christmas053.svg',
'Christmas/Christmas054.svg',
'Christmas/Christmas055.svg',
'Christmas/Christmas057.svg',
'Christmas/Christmas060.svg',
'Christmas/Christmas062.svg',
'Christmas/Christmas063.svg',
'Christmas/Christmas064.svg',
'Christmas/Christmas065.svg',
'Christmas/Christmas069.svg',
'Christmas/Christmas070.svg',
'Christmas/Christmas071.svg',
'Christmas/Christmas074.svg',
'Christmas/Christmas075.svg',
'Christmas/Christmas081.svg',
'Christmas/Christmas082.svg',
'Christmas/Christmas083.svg',
'Christmas/Christmas084.svg',
'Christmas/Christmas085.svg',
'Christmas/Christmas086.svg',
'Christmas/Christmas087.svg',
'Christmas/Christmas088.svg',
'Christmas/Christmas089.svg',
'Christmas/Christmas090.svg',
'Christmas/Christmas091.svg',
'Christmas/Christmas092.svg',
'Christmas/Christmas093.svg',
'Christmas/Christmas094.svg',
'Christmas/Christmas095.svg',
'Christmas/Christmas096.svg',
'Christmas/Christmas101.svg',
'Christmas/Christmas107.svg',
'Christmas/Christmas108.svg',
'Christmas/Christmas109.svg',
'Christmas/Christmas116.svg',
'Christmas/Christmas122.svg',
'Christmas/Christmas123.svg',
'Christmas/Christmas124.svg',
'Christmas/Christmas125.svg',
'Christmas/Christmas126.svg',
'Christmas/Christmas127.svg',
'Christmas/Christmas128.svg',
'Christmas/Christmas129.svg',
'Christmas/Christmas130.svg',
'Christmas/Christmas131.svg',
'Christmas/Christmas133.svg',
'Christmas/Christmas140.svg',
'Christmas/Christmas141.svg',
'Christmas/Christmas142.svg',
'Christmas/Christmas143.svg',
'Christmas/Christmas144.svg',
'Christmas/Christmas145.svg',
'Christmas/Christmas146.svg',
'Christmas/Christmas147.svg',
'Christmas/Christmas148.svg',
'Christmas/Christmas149.svg',
'Christmas/Christmas150.svg',
'General/General021.svg',
'General/General000.svg',
'General/General001.svg',
'General/General002.svg',
'General/General003.svg',
'General/General004.svg',
'General/General005.svg',
'General/General006.svg',
'General/General007.svg',
'General/General008.svg',
'General/General009.svg',
'General/General010.svg',
'General/General011.svg',
'General/General012.svg',
'General/General014.svg',
'General/General015.svg',
'General/General016.svg',
'General/General017.svg',
'General/General018.svg',
'General/General025.svg',
'General/General026.svg',
'General/General027.svg',
'General/General028.svg',
'General/General029.svg',
'General/General030.svg',
'General/General033.svg',
'General/General034.svg',
'General/General035.svg',
'General/General036.svg',
'General/General037.svg',
'General/General038.svg',
'General/General046.svg',
'General/General047.svg',
'General/General048.svg',
'General/General049.svg',
'General/General060.svg',
'General/General061.svg',
'General/General062.svg',
'Love/Love020.svg',
'Love/Love024.svg',
'Love/Love036.svg',
'Love/Love000.svg',
'Love/Love004.svg',
'Love/Love010.svg',
'Love/Love013.svg',
'Love/Love015.svg',
'Love/Love016.svg',
'Love/Love018.svg',
'Love/Love019.svg',
'Love/Love020.svg',
'Love/Love021.svg',
'Love/Love022.svg',
'Love/Love023.svg',
'Love/Love024.svg',
'Love/Love026.svg',
'Love/Love027.svg',
'Love/Love039.svg',
'Love/Love040.svg',
'Love/Love041.svg',
'Love/Love042.svg',
'Love/Love048.svg',
'Love/Love049.svg',
'Love/Love050.svg',
'Love/Love052.svg',
'Love/Love053.svg',
'Love/Love054.svg',
'Love/Love065.svg',
'Love/Love070.svg',
'Love/Love072.svg',
'Love/Love076.svg',
'Love/Love077.svg',
'Love/Love078.svg',
'Love/Love079.svg',
'Love/Love080.svg',
'Love/Love081.svg',
'Love/Love082.svg',
'Love/Love083.svg',
'Love/Love084.svg',
'Love/Love085.svg',
'Love/Love086.svg',
'Shapes/Shapes020.svg',
'Shapes/Shapes021.svg',
'Shapes/Shapes000.svg',
'Shapes/Shapes001.svg',
'Shapes/Shapes002.svg',
'Shapes/Shapes003.svg',
'Shapes/Shapes004.svg',
'Shapes/Shapes005.svg',
'Shapes/Shapes006.svg',
'Shapes/Shapes007.svg',
'Shapes/Shapes008.svg',
'Shapes/Shapes009.svg',
'Shapes/Shapes010.svg',
'Shapes/Shapes011.svg',
'Shapes/Shapes012.svg',
'Shapes/Shapes026.svg',
'Shapes/Shapes027.svg',
'Shapes/Shapes028.svg',
'Shapes/Shapes029.svg',
'Shapes/Shapes030.svg',
'Shapes/Shapes031.svg',
'Shapes/Shapes032.svg',
'Shapes/Shapes033.svg',
'Shapes/Shapes034.svg',
'Shapes/Shapes035.svg',
'Shapes/Shapes036.svg',
'Shapes/Shapes037.svg',
'Shapes/Shapes038.svg',
'Shapes/Shapes057.svg',
'Shapes/Shapes058.svg',
'Shapes/Shapes059.svg'];
//building dictionary for faster access, and just in case, changing all to lower case:
var black_dict = new Array();
$.each(stickers_black_list, function (idx, elem) {
black_dict[elem.toLowerCase()] = null;
});
//sorted by category
thisController.all_stickers_by_category = new Array();
//birthday catgory:
var generateCategoryStickersArray = function (base_svg_filename, svg_idx_start, svg_idx_end, thumb_sprite_filename, thumb_y_start, thumb_y_diff) {
//this method generates comptaible stickers array, according to a sprite with a known inner-logic of stickers.
//example for such array: [
// { filename: "Birthday/Birthday001.svg", thumb_filename: "Birthday/birthday-sprite.png", thumb_x: 0, thumb_y: 60 },
// { filename: "Birthday/Birthday002.svg", thumb_filename: "Birthday/birthday-sprite.png", thumb_x: 0, thumb_y: 120 },
// { filename: "Birthday/Birthday003.svg", thumb_filename: "Birthday/birthday-sprite.png", thumb_x: 0, thumb_y: 180 },
// { filename: "Birthday/Birthday004.svg", thumb_filename: "Birthday/birthday-sprite.png", thumb_x: 0, thumb_y: 240 } ]
var curr_y = thumb_y_start;
var ret = new Array();
var idx;
for (idx = svg_idx_start; idx <= svg_idx_end; idx++) {
//mkaing sure strIdx is 999 (00x, 0xx)
var strIdx = idx;
if (idx < 10) strIdx = '00' + idx;
else if (idx < 100) strIdx = '0' + idx;
var sticker_filename = base_svg_filename.replace('{0}', strIdx);
//console.log("Stciker", sticker_filename);
//DZ 20sep15: if sticker is not black-listed:
if (!black_dict.hasOwnProperty(sticker_filename.toLowerCase())) {
ret[ret.length] = {
filename: sticker_filename,
thumb_filename: thumb_sprite_filename,
thumb_x: 0,
thumb_y: curr_y
};
}
curr_y += thumb_y_diff;
}
return ret;
};
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Animals/Animals{0}.svg", 0, 145, "Animals\\Animals-sprite.png", 0, 60).reverse();;
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Birthday/Birthday{0}.svg", 0, 145, "Birthday\\Birthday-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Children/Children{0}.svg", 0, 215, "Children\\Children-sprite.png", 0, 60);
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Christmas/Christmas{0}.svg", 0, 209, "Christmas\\Christmas-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Floral/Floral{0}.svg", 0, 174, "Floral\\Floral-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("General/General{0}.svg", 0, 137, "General\\General-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Holidays/Holidays{0}.svg", 0, 221, "Holidays\\Holidays-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Love/Love{0}.svg", 0, 163, "Love\\Love-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Party/Party{0}.svg", 0, 188, "Party\\Party-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Shapes/Shapes{0}.svg", 0, 102, "Shapes\\Shapes-sprite.png", 0, 60).reverse();
thisController.all_stickers_by_category[thisController.all_stickers_by_category.length] = generateCategoryStickersArray("Babies/Baby{0}.svg", 0, 48, "Babies\\Babies-sprite.png", 0, 60);
if (inMobileMode)
//MOBILE: binds all stickers inside one scroll
uxController.bind_stickers_to_mobile_ux();
else
//DESKTOP: binds all stickers into groups (and dropdown)
//YZ 24-Nov-15:Adding support for default stickers category
//DZ 29nov15: but not for admin
if (!is_admin_mode && stickerCategoryId != '') {
uxController.bind_stickers_by_category(stickerCategoryId);
//stickerCategoryName = $('#stickers_dropdown li[category_id=' + stickerCategoryId + ']').text();
//$('#stickers_dropdown .selected p').empty().text(stickerCategoryName);
//$('#stickers_dropdown').val(stickerCategoryId);
}
else
uxController.bind_stickers_by_category(0);
}
//SAVING PROCESS: SAVE PROCESS:
//private
function saveUserCard(succFunc, failFunc) {
//IMPORTANT: this method is 2 clones saveUserCard / saveCardForPrinting - make sure to update relevant fixes on both
//step 1: upload all relevant images to cloud
//gather all relevant user images:
var saveResourcesUrls = [];
var jqPhotoSlotsWithImages = $('.has_photo.slot_photo:not(".invis")');
//RECURSIVE on all image decors:
//save all resources:
desLogic.saveUserResourceRecursive("CardUserPhoto", jqPhotoSlotsWithImages, saveResourcesUrls, 0, function () {
//now we've finished saving photos, we save stickers:
thisController.saveCustomStickers(saveResourcesUrls, function () {
var savedJson = thisController.get_export_json("CardUserPhoto");
debug.log('Saving JSON to server');
//YZ 31Jan16: Saving a thumbnail image for saved invites
if (editorMode == 'invitations') {
var dimensions = desLogic.getOrderRenderDimensions(renderDimensions.thumbnail);
now_rendering_without_watermark = true;
render_image_from_frame($('.tabFront .editorFrame'), dimensions.width, dimensions.height, function (thumb_img_src) {
desLogic.saveImage(thumb_img_src, 'UserCardThumbnail')
.then(function () {
saveCard($('#user_save_name').val(), savedJson, saveResourcesUrls).then(succFunc, failFunc);
now_rendering_without_watermark = false;
}, function () { //failed to save image - save card anyway
saveCard($('#user_save_name').val(), savedJson, saveResourcesUrls).then(succFunc, failFunc);
now_rendering_without_watermark = false;
});
}, 0.99);
}
else {
saveCard($('#user_save_name').val(), savedJson, saveResourcesUrls).then(succFunc, failFunc);
}
}, failFunc); //failed to save stickers
}, failFunc); //failed to save photos
}
//DT: save invitation images and data // mode online_invitations
function saveOnlineInvitationImages() {
var saveResourcesUrls = [];
var jqPhotoSlotsWithImages = $('.has_photo.slot_photo:not(".invis")');
var deferred = new $.Deferred();
//RECURSIVE on all image decors:
//save all resources:
desLogic.saveUserResourceRecursive("CardUserPhoto", jqPhotoSlotsWithImages, saveResourcesUrls, 0, function () {
//now we've finished saving photos, we save stickers:
thisController.saveCustomStickers(saveResourcesUrls, function () {
var savedJson = thisController.get_export_json();
var resolve = function () {
deferred.resolve({
imageUrls: saveResourcesUrls,
userCardCode: onlineInvitation.id !== "" ? userCardCode : null,
cardId: cardId,
sectionId: sectionId,
cardDesign: JSON.stringify(savedJson),
saveName: $("").html($('#user_save_name').val()).text()
});
};
resolve();
}, function () { deferred.reject(); }, "online_invitation"); //failed to save stickers
}, function () { deferred.reject(); }, "online_invitation"
); //failed to save photos
return deferred.promise();
}
//YZ 17/12/18 - mode can be "save_draft" or "online_invitation"
this.recursiveSaveStickers = function (jqStickerSlots, currentIdx, saveResourcesUrls, innerSuccFunc, innerFailFunc, mode) {
mode = typeof mode === "undefined" ? "save_draft" : mode;
if (currentIdx == jqStickerSlots.length) {
//END CONDITION
debug.log('saveCustomStickers ' + currentIdx + '..\\index.html' + jqStickerSlots.length + ' - END condition reached');
innerSuccFunc();
}
else {
var currentSticker = $(jqStickerSlots[currentIdx]);
var imgSrc = currentSticker.find('.sticker_container_inner img').attr('src');
var isBase64 = imgSrc.length > 1024;
var isSticker = imgSrc.toLowerCase().indexOf("sticker") > -1;
//YZ 17/12/18 - for "online_invitation" we always save, unless a real sticker from stickers collection
if ((!isBase64 && mode !== "online_invitation") || isSticker) {
debug.log('saveCustomStickers ' + currentIdx + '..\\index.html' + jqStickerSlots.length + ' - not base64, not uploading');
if (!isSticker) { //no need to save url for stickers
saveResourcesUrls.push(imgSrc); //YZ 17Dec18
}
thisController.recursiveSaveStickers(jqStickerSlots, currentIdx + 1, saveResourcesUrls, innerSuccFunc, innerFailFunc, mode);
}
else {
//upload:
debug.log('saveCustomStickers ' + currentIdx + '..\\index.html' + jqStickerSlots.length + ' - uploading');
var uploadStickerToServer = function (imgSrc) {
//YZ 17/12/18 - using different save function for online_invitation
var saveImagefunc = mode === "online_invitation" ? desLogic.SaveImageForOnlineInvitation : desLogic.saveImage;
saveImagefunc(imgSrc, 'UserCustomSticker').then(function (serverRet) {
//promise succ:
if (serverRet.error != 0) {
debug.error('upload promise failed - server returned non zero error code', serverRet);
innerFailFunc(serverRet);
}
else {
debug.log('saveCustomStickers ' + currentIdx + '..\\index.html' + jqStickerSlots.length + ' - UPLOADED successfully', serverRet);
//succses - recursive call to next image:
//updte dom with new URL:
var newUrl = serverRet.url;
saveResourcesUrls.push(newUrl);
currentSticker.find('.sticker_container_inner img').attr('src', newUrl);
//Recursive call:
thisController.recursiveSaveStickers(jqStickerSlots, currentIdx + 1, saveResourcesUrls, innerSuccFunc, innerFailFunc, mode);
}
}, function (errorDesc) {
debug.error('sticker upload promise failed', errorDesc);
innerFailFunc();
});
};
uploadStickerToServer(imgSrc);
}
}
};
//YZ 17/12/18 - mode can be "save_draft" or "online_invitation"
this.saveCustomStickers = function (saveResourcesUrls, succFunc, failFunc, mode) {
mode = typeof mode === "undefined" ? "save_draft" : mode;
var allStickers = $('.editorTab .sticker_container');
thisController.recursiveSaveStickers(allStickers, 0, saveResourcesUrls, function () {
console.log("finished saving stickers");
succFunc();
}, function (err) {
console.error("failed saving stickers", err);
}, mode);
};
//ultity method for saveUserCard / saveCardForPrinting (save_user_resource_recursive)
//public - save user images to cloud
this.saveUserResourceRecursive = function (saveImageType, jqPhotoSlotsWithImages, saveResourcesUrls, currentIdx, succFunc, failFunc, mode) {
mode = typeof mode === "undefined" ? "save_draft" : mode;
if (currentIdx == jqPhotoSlotsWithImages.length) {
//END CONDITION
debug.log('saveUserResource ' + currentIdx + '..\\index.html' + jqPhotoSlotsWithImages.length + ' - END condition reached');
succFunc();
}
else {
var jqPhotoSlot = $(jqPhotoSlotsWithImages[currentIdx]);
var filterName = jqPhotoSlot.attr('filter_name');
var hasFilter = filterName != null && filterName.trim() != '' && filterName !== 'no-filter';
var imgSrc = hasFilter ? jqPhotoSlot.attr('unfiltered_src') : jqPhotoSlot.find('.photo_holder img').attr('src');
var isBase64 = imgSrc.length > 1024;
if (!isBase64 && mode !== "online_invitation") {
debug.log('saveUserResource ' + currentIdx + '..\\index.html' + jqPhotoSlotsWithImages.length + ' - not base64, not uploading');
saveResourcesUrls.push(imgSrc);
//DZ 11jan16 fix:
//succFunc();
//Recursive call:
desLogic.saveUserResourceRecursive(saveImageType, jqPhotoSlotsWithImages, saveResourcesUrls, currentIdx + 1, succFunc, failFunc, mode);
}
else {
//upload:
debug.log('saveUserResource ' + currentIdx + '..\\index.html' + jqPhotoSlotsWithImages.length + ' - uploading');
//this method will run once we know we have the final (compressed if required) image
//upload to server, userupload
var uploadImageToServer = function (imgSrc) {
//DZ 24dec17: notice saveImage is overridden on SAM
//YZ 17/12/18 - using different save function for online_invitation
var saveImagefunc = mode === "online_invitation" ? desLogic.SaveImageForOnlineInvitation : desLogic.saveImage;
saveImagefunc(imgSrc, saveImageType).then(function (serverRet) {
//promise succ:
if (serverRet.error != 0) {
debug.error('upload promise failed - server returned non zero error code', serverRet);
failFunc(serverRet);
}
else {
debug.log('saveUserResource ' + currentIdx + '..\\index.html' + jqPhotoSlotsWithImages.length + ' - UPLOADED successfully', serverRet);
//succses - recursive call to next image:
//updte dom with new URL:
var newUrl = serverRet.url;
saveResourcesUrls.push(newUrl);
//DZ 5nov15: doing this only for save scenario - [AD-15] Make sure uploaded images are saved in the correct bucket
//if (saveImageType === "CardUserPhoto") {
//DZ 26jan16: changing back to single bucket design
if (hasFilter)
jqPhotoSlot.attr('unfiltered_src', newUrl);
else
jqPhotoSlot.find('.photo_holder img').attr('src', newUrl);
//DZ 9apr18: adding relative URL for SAM storage
if (editorAppMode == 'SAM')
jqPhotoSlot.attr('sam-relative-url', serverRet.samRelativeUrl);
//Recursive call:
desLogic.saveUserResourceRecursive(saveImageType, jqPhotoSlotsWithImages, saveResourcesUrls, currentIdx + 1, succFunc, failFunc, mode);
}
}, function (errorDesc) {
debug.error('upload promise failed', errorDesc);
failFunc();
});
};
async_create_and_load_image(imgSrc, function (img) {
//YZ 11oct15: removed resize if image > 1000
uploadImageToServer(imgSrc);
});
}
}
};
//public
this.get_export_json = function (saveImageType) {
var ret = {
pages: []
};
//DZ 1mar15: putting selected layout here:
//DZ 11sep17: ecards_v2 support
//if (editorMode == 'cards' || editorMode == 'ecards')
if (editorMode != 'invitations')
//dz 15JUN15: changed here (and 1-2 more places) from #main to .main according to CSS cahnges by andru
ret.selectedLayoutIdx = $('body').attr('selected_card_layout');
$('.editorFrame').each(function () {
var objPage = {
textElements: [],
photoElements: [],
stickerElements: []
};
var thisFrame = $(this);
//decors can be:
//1. movable/freesize text slots
//2. customtext static placed textslots
//3. image slots
//4. stickers
//1 and 2
thisFrame.find('.slot_text').each(function () {
var domDecor = $(this);
var domInnerTextarea = domDecor.find('textarea');
var text = domInnerTextarea.val();
//if has text inside:
if (text != '') {
//get all propeties of text decor:
var objDecor = {};
objDecor.text = text;
objDecor.fontFamily = domInnerTextarea.css('font-family');
objDecor.fontSize = domInnerTextarea.css('font-size');
objDecor.textAlign = domInnerTextarea.css('text-align');
objDecor.color = domInnerTextarea.css('color');
if (domDecor.hasClass('freesize')) {
//objDecor.type = "text_freesize";
objDecor.left = domDecor.css('left');
objDecor.top = domDecor.css('top');
objDecor.marginLeft = domDecor.css('margin-left');
//DZ 19jul15: saving rotation for text element
var rotationDegress = get_rotation_degress_of_element(domDecor);
if (rotationDegress != 0)
objDecor.rotation = rotationDegress;
}
else {
//objDecor.type = "text_customtextarea"; //only used in cards, inner pages
objDecor.indexInPage = thisFrame.find('.slot_text').index(domDecor); //index relative to other text fields
}
objPage.textElements.push(objDecor);
}
});
//3. image slots:
thisFrame.find('.slot_photo.has_photo:not(".invis")').each(function () {
var jqPhotoSlot = $(this);
var domInnerImage = jqPhotoSlot.find('.photo_holder img');
var objPhoto = {};
var filterName = jqPhotoSlot.attr('filter_name');
var hasFilter = filterName != null && filterName.trim() != '' && filterName !== 'no-filter';
objPhoto.filterName = filterName;
//DZ 26jan16: changing back to single bucket design
//if (saveImageType === "CardUserPhoto") {
if (hasFilter)
objPhoto.src = jqPhotoSlot.attr('unfiltered_src'); //should be url
else
//DT 20Dec17: (AD-111) get image url instead inline image
objPhoto.src = jqPhotoSlot.find('.photo_holder img').data('src') || jqPhotoSlot.find('.photo_holder img').attr('src');
//DZ 9apr18: storing also relative URL for SAM
if (editorAppMode == 'SAM')
objPhoto.samRelativeUrl = jqPhotoSlot.attr('sam-relative-url');
objPhoto.matrix = domInnerImage.panzoom('getMatrix'); //contains pan/zoom params
objPhoto.frameName = $(this).attr('current_frame');
objPhoto.indexInPage = thisFrame.find('.slot_photo').index($(this)); //index relative to other text fields
objPage.photoElements.push(objPhoto);
});
//4. stickers:
thisFrame.find('.sticker_container').each(function () {
var domDecor = $(this);
var objDecor = {};
objDecor.left = domDecor.css('left');
objDecor.top = domDecor.css('top');
objDecor.width = domDecor.css('width');
objDecor.height = domDecor.css('height');
objDecor.src = domDecor.find('.sticker_container_inner img').attr('src');
objPage.stickerElements.push(objDecor);
});
ret.pages.push(objPage);
});
//debug.log('get_export_json', ret);
return ret;
};
//private
function getSavedJsonStringForStats() {
var savedJson = desLogic.get_export_json("CardUserPhoto");
var savedJsonString = JSON.stringify(savedJson);
//make sure saved json isnt too long:
if (savedJsonString.length > 20000) {
savedJsonString.length = 20000;
console.warn('looks like something went wrong. saved json length is ' + savedJsonString.length);
}
};
//public:
//this method binds the finish popup used both for invitations and ecards
//DZ 11sep17: NOT TO ECARDS ANYMORE. ecards_v2 is handled in the cards finish popup
this.bind_finish_tabs_popup = function () {
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards') {
// //we share the same popup for ecaards and invtations, but we remove the 'print' tab and change order of tabs:
// $('#popup_finish_tabs .REMOVED_ON_ECARDS').remove();
// $("#popup_finish_tabs .tabs-nav li:nth-child(1)").before($("#popup_finish_tabs .tabs-nav li:nth-child(2)"));
// $("#finish_tab_invi_download").before($("#finish_tab_invi_share"));
// $('#popup_finish_tabs .tabs-nav .active, #popup_finish_tabs .tab-content.active').removeClass('active');
// $('#popup_finish_tabs .tabs-nav li:nth-child(1),#finish_tab_invi_share').addClass('active');
//}
//23jul17: binding 'remove watermark' checkbox:
if (editorMode == 'invitations') {
///checkbox action
$('#popup_finish_tabs .onoffswitch input').change(function () {
var now_checked = $(this).prop('checked');
//we clone the input for 2 tabs, so we adjust all according to the new value:
$('#popup_finish_tabs .onoffswitch input').prop('checked', now_checked);
$('#btn_download_from_tabs_popup .btn-text').text(now_checked ? localizationDict['Pay_Download'] : localizationDict['Download']);
$('#btn_invitations_print_from_popup .btn-text').text(now_checked ? localizationDict['Pay_Print'] : localizationDict['Print']);
//$('#popup_finish_tabs .preview-section').toggleClass('watermark-on-preview', !now_checked);
show_invi_previews_according_to_watermark_selection();
});
if (!is_admin_mode && editorAppMode !== 'SAM') {
//YZ 5/9/17 - getting price to show from server
$(".watermark-text .price").append(premium_remove_watermark.currency.CurrencySymbol, premium_remove_watermark.price.toString(), " ", premium_remove_watermark.currency.ISOCurrencySymbol);
$(".watermark-text .marked-price").append(premium_remove_watermark.currency.CurrencySymbol, Math.round(parseFloat(premium_remove_watermark.price.toString()) * 1.42));
var alreadyPaidForWatermarkRemoval = false;
try {
alreadyPaidForWatermarkRemoval = premium_remove_watermark.initial_state == "PAID";
}
catch (e) {
console.error("failed getting APFWR", e);
}
if (getAppFeatureFlag('editor_premium_watermark_feature_enabled')) {
$('#popup_finish_tabs .onoffswitch input').prop('checked', alreadyPaidForWatermarkRemoval);
}
else {
$('#popup_finish_tabs .premium_remove_watermark').remove();
$('#popup_finish_tabs .has-footer-md').removeClass('has-footer-md').addClass('has-footer');
}
}
//bind tooltip for watermark:
//YZ 18/7/17:binding the 'remove watermark' tooltip
if ($().qtip) {
$('.watermark-tooltip').each(function () {
$(this).qtip({
show: { event: 'mouseenter touchstart' },
content: {
text: $(this).next('.watermark-tooltip-content')
},
position: {
my: 'center right',
at: 'center left',
viewport: $(window),
adjust: {
method: 'flip flip'
}
},
style: {
classes: 'tooltip-simple',
tip: {
border: false,
width: 16,
height: 8
}
}
});
});
};
}
//method that changes preview according to radiobuttons/selections/tab on finish popup:
thisController.func_update_invitations_preview_panel = function () {
//DOWNLOAD tab:
setTimeout(function () {
console.log('func_update_invitations_preview_panel');
//timeout hotfix so click handler for layout-option will be handled before this runs
var previewType; //pagesheet or image
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//var previewPdfNumPerPage = (editorMode == 'ecards') ? 1 : $('#popup_finish_tabs .layout-options:visible .layout-option.-active').attr('num_per_page');
var previewPdfNumPerPage = $('#popup_finish_tabs .layout-options:visible .layout-option.-active').attr('num_per_page');
//14sep17: adding preview section support for 3d cards:
var shouldIncludePreviewLink = false;
var tabName = $('#popup_finish_tabs .tabs-nav li.active').attr('data-tab-name');
switch (tabName) {
case 'download':
//previewType = 'image';
previewType = $('input[name="download_type"]:checked').val() == 'download_image' ? 'image' : 'pagesheet'; //e.g. "download_image" or "download_pdf"
break;
case 'print':
previewType = 'pagesheet';
break;
case 'share':
previewType = 'image';
shouldIncludePreviewLink = true;
break;
}
//DZ 14sep17:
$('#popup_finish_tabs .preview-section').toggleClass('preview-section-shown', shouldIncludePreviewLink);
if (previewType == "image") {
//$('#popup_finish_tabs .preview-section .download-preview').show();
$('#popup_finish_tabs .preview-section .download-preview').removeClass('invis');
$('#popup_finish_tabs .preview-section .page_sheet').hide();
}
else {
//$('#popup_finish_tabs .preview-section .download-preview').hide();
$('#popup_finish_tabs .preview-section .download-preview').addClass('invis');
$('#popup_finish_tabs .preview-section .page_sheet')
.removeClass('invit-per-page-1')
.removeClass('invit-per-page-2')
.removeClass('invit-per-page-4')
.addClass('invit-per-page-' + previewPdfNumPerPage)
.show();
}
thisController.autoscale_finish_preview();
}, 0);
};
//first time init:
thisController.func_update_invitations_preview_panel();
//radios actions:
$('#popup_finish_tabs input[type="radio"]').change(thisController.func_update_invitations_preview_panel);
$('#popup_finish_tabs .layout-option').click(thisController.func_update_invitations_preview_panel);
//DZ 2mar17: (ND-159)
if (typeof isRSVP !== "undefined" && isRSVP) {
//no options for PDF, num_per_page=4
$('#download-pdf-options').css('visibility', 'hidden');
$('#download-pdf-options .layout-option').removeClass('-active')
$('#download-pdf-options .layout-option[num_per_page=4]').addClass('-active')
//one option for Print - 4 per page
$('#print-options .layout-option').hide().removeClass('-active');
$('#print-options .layout-option[num_per_page=4]').show().addClass('-active');
}
//clicking free downlod - can be image, pdf (customizable # in page)
$('#btn_download_from_tabs_popup').click(function () {
var downloadType = $('input[name="download_type"]:checked').val();
if (downloadType == "download_image") {
//download image:
//if (inMobileMode)
// desLogic.close_popups_or_drawers();
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards') {
// $.publish('designer.download_fileType', ['jpeg']);
// download_ecard_as_jpeg();
//}
//else {
process_finish_with_watermark_action(function () {
$.publish('designer.download_fileType', ['jpeg']);
download_invitation_as_jpeg();
desLogic.mark_as_clean();
});
//}
}
else {
//download pdf:
$.publish('designer.download_fileType', ['pdf']);
//thisController.close_all_popups();
desLogic.close_popups_or_drawers();
if (isIE9)
thisController.open_incompatible_browser_popup();
else {
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards')
//download_ecard_as_pdf();
//else {
process_finish_with_watermark_action(function () {
var num_per_page = $('#popup_finish_tabs #download-pdf-options .layout-option.-active').attr('num_per_page');// .hasClass('-one') ? 1 : jqActiveSelection.hasClass('-two') ? 2 : 4;
download_invitation_as_pdf(num_per_page);
});
//}
}
}
});
$('#btn_invitations_print_from_popup').click(function () {
var jqActiveSelection = $('#popup_finish_tabs #print-options .layout-option.-active');
var num_per_page = jqActiveSelection.attr('num_per_page');
process_finish_with_watermark_action(function () {
//SAM NOTE: moved this to IONIC scope
$.publish('designer.print', [editorMode, { 'invites_per_page': num_per_page }]);
print_invitation(num_per_page);
});
//DZ REDEISNG 22jan17: skipping this logic
//$.publish('designer.print_click', [editorMode]);
//if (typeof isRSVP !== "undefined" && isRSVP) {
// $.publish('designer.print', [editorMode, { 'invites_per_page': 4 }]);
// print_invitation(4);
//}
});
//DZ 11sep17: splitting to new method (used to exist only for invitations modal):
bind_send_online_finish_tab();
};
function bind_send_online_finish_tab() {
//DZ 11mar18: SAM code merge (old irrelevant code?)
if (editorAppMode === "SAM" && editorMode != 'invitations')
{
$('.link-for-online-preview strong').each(function () {
$(this).text($(this).text().replace('invitation', 'card'));
});
}
//DZ 25sep17: action for 'preview 3d card/ecard/invi'
$('.link-for-online-preview').click(function () {
//opening relevant popup or drawer:
if (inMobileMode)
uxController.open_drawer('#preview-3d-drawer');
else {
uxController.show_popup($('#popup_3d_preview'));
$("body").css("overflow", "hidden");
}
desLogic.preview3d_detect_and_upload_modified_pages_previews('render', function (urlArray) {
init3D(urlArray);
});
$('#popup_3d_preview').on('click',
'.close_preview',
function () {
dispose3D();
uxController.hide_popup($('#popup_3d_preview'));
$("body").css("overflow", "");
});
});
//YZ 1/Oct/17 - emptying 3d preview to free memory
//TODO: Call a proper destructor of 3d app
//TODO: Apply on desktop
if (inMobileMode) {
$('#preview-3d-drawer').on('hide.effects-drawer', function (e) {
dispose3D();
});
}
bind_send_online_events();
}
//DZ 23jul17, 24jul17:
//this method will aquire watermark privligies (buy, or from previous buy) if asked for and continue to action after
//this method has no failFunc now (TODO?) - will only write to error log (in case user cancels etc)
function process_finish_with_watermark_action(succFunc) {
var premium_no_watermark_selected = $('#premium_no_watermark_onoff').is(':checked');
if (!premium_no_watermark_selected) {
console.log('PREM_NO_WAT - no watermark selected');
succFunc();
}
else {
//first authenticate user:
console.log('PREM_NO_WAT - authenticating');
//true = force sync api
var dialogToShow = (typeof showDialog !== "undefined" && showDialog === "signup") ? "register" : "login";
//YZ 31/7/18 - experimenting login vs signup dialogs
authenticate(true, dialogToShow).done(function (d) {
//CALLBACK 1
//YZ 25/7/17:opening the window (blank) here and pass it to process_paypal_payment to prevent it blocked by popup blockers
//DZ: to avoid popup-blockers - opening window before necessary, redirecting (if) becomes necessary, close if not necessary
var opened_paypal_window = window.open('', "Payment Dialog", 500, 400, "menubar=0,toolbar=0");
opened_paypal_window.document.write('Redirecting to PayPal...');
console.log('PREM_NO_WAT - authed');
var authd = d;
authd.withoutrefresh = true;
afterauth.resolve(authd);
//now, need to figure out if already watermark paid for, if not - popup payment modal
get_is_premium_watermark_paid_for(function (wasPaidFor) {
//CALLBACK 2
if (wasPaidFor) {
console.log('PREM_NO_WAT - already paid for');
//renderer will take it from here:
premium_watermark_removal_was_paid = true;
//needed only in cases where initially user was not logged on
set_buy_premium_watermark_section();
//Payment window isnt needed anymore
//console.log('closing it');
opened_paypal_window.close();
succFunc();
}
else {
console.log('PREM_NO_WAT - wasnt paid for before. going for paypal');
process_paypal_payment(opened_paypal_window, function (payPalResp) {
//if paypal succcedded:
console.log('PREM_NO_WAT - paypal OK');
get_is_premium_watermark_paid_for(function (isPaidFor) {
//isPaidFor is bool
if (isPaidFor) {
console.log('PREM_NO_WAT paid for');
premium_watermark_removal_was_paid = true;
set_buy_premium_watermark_section();
succFunc();
}
else {
console.error('PREM_NO_WAT - api returned not paid for, after paypal finished');
//not throwing error here - might be caused because of user cancel
//desLogic.show_unexpected_error_msg();
}
});
}, function (payPalFailure) {
//paypal failure
console.log('PREM_NO_WAT - paypal failure', payPalFailure);
thisController.show_unexpected_error_msg();
});
}
});
});
}
}
function process_paypal_payment(paypalWindow, succFunc, failFunc) {
$.post('..\\MS_104.html',
//{ cardId:cardId, code: get_premium_watermark_code() },
{ cardId: cardId },
function (r) {
var promise = new $.Deferred();
//required by paypal
window.getPromise = function () {
return promise;
}
paypalWindow.location.href = r.paymentUrl;
//window.open(r.paymentUrl, "Payment Dialog", 500, 500, "menubar=0,toolbar=0");
promise.done(function (r) {
console.log('Paypal returned', r);
//we call verify after this anyway - so no need to process paypal response
succFunc(r);
}).fail(function (failRMP) {
console.error("PP failed", failRMP);
failFunc();
});
}
).fail(function (failRMP) {
console.error("RemoveMarkPayment failed", failRMP);
failFunc();
});
}
function get_is_premium_watermark_paid_for(succFunc) {
$.post('..\\MS_103.html', { cardId: cardId/*, code: get_premium_watermark_code()*/ }, function (r) {
succFunc(r.valid);
}).fail(function (err) {
console.error('VerifyRemoveMark failed', err);
thisController.show_unexpected_error_msg();
});
}
//function get_premium_watermark_code() {
// return premium_remove_watermark.code;
//}
//public
this.autoscale_finish_preview = function () {
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (inMobileMode && (editorMode == 'invitations' || editorMode == 'ecards')) {
if (inMobileMode && editorMode == 'invitations') {
var jqPreviewSection = $('#popup_finish_tabs .preview-section');
var max_width = jqPreviewSection.width() - 20;
var max_height = jqPreviewSection.height() - 20;
//DZ 14sep17: leaving space for 3d-preview-link
if (jqPreviewSection.hasClass('preview-section-shown') && !$('html').hasClass('landscape-mode')) {
max_height -= 50;
console.log('leaving space.--------------');
}
//only 1 from these:
var visible_preview_element = jqPreviewSection.find('.page_sheet:visible,.download-preview:visible');
var default_transform = 'translateY(-50%) translateX(-50%) ';
visible_preview_element.css('transform', default_transform);
//resize by width (if needed)
if (visible_preview_element.width() > max_width) {
var newPreviewScale = max_width / visible_preview_element.width();
visible_preview_element.css('transform', default_transform + ' scale(' + newPreviewScale + ')');
console.log('autoscaling_finish_preview - by width');
}
//resize by height (if needed)
if (visible_preview_element.height() > max_height) {
var newPreviewScale = max_height / visible_preview_element.height();
visible_preview_element.css('transform', default_transform + ' scale(' + newPreviewScale + ')');
console.log('autoscaling_finish_preview - by height');
}
}
}
//public - this method binds the finish popup for CARDS
//DZ 11sep17: also for ecards_v2
this.bind_cards_finish_tabs_popup = function () {
desLogic.func_update_preview_panel = function (e) {
//we cloned 2 groups of radios for the 2 tabs. if event is caused by change we update the 'other' cloned radio
if (e != null && e.target != null) {
//console.log('jq ee', e);
//the input's group that was just changed e.g. print_summary_card_size_CLONED
var newValueSelected = e.target.value;
var changedGroupName = e.target.name;
var targetGroupName = changedGroupName.indexOf('_CLONED') > 0 ? changedGroupName.replace('_CLONED', '') : changedGroupName + '_CLONED';
$("input[name=" + targetGroupName + "][value='" + newValueSelected + "']").prop("checked", true);
//DZ 17aug17: now also cloned dropdown for a4/letter
if (e.target.id.indexOf('page_size_dropdown') > -1) {
//console.log('innn', e.target.id);
if (e.target.id.indexOf('_CLONED') > -1) {
$('#page_size_dropdown').val($('#page_size_dropdown_CLONED').val()).trigger('change.select2');;
//console.log('updating from ', $('#page_size_dropdown_CLONED').val(), ' to ', $('#page_size_dropdown').val());
}
else
$('#page_size_dropdown_CLONED').val($('#page_size_dropdown').val()).trigger('change.select2');;
}
//if (changedGroupName.indexOf('_CLONED') > 0)
}
var isFullLayout = $('input:radio[name=print_summary_card_size]').filter(":checked").val() == 'full';
//DZ 17aug17: dropdown for this shit page_size_dropdown_CLONED
//var isA4 = $('input:radio[name=print_summary_page_size]').filter(":checked").val() == 'a4';
var isA4 = $('#page_size_dropdown').val() == 'a4';
//$('#print_summary_preview .page_sheet').toggleClass('a4', isA4);
//$('#print_summary_preview .generated_preview_page').toggleClass('full_layout', isFullLayout);
$('.print_summary_preview .page_sheet').toggleClass('a4', isA4);
$('.print_summary_preview .generated_preview_page').toggleClass('full_layout', isFullLayout);
//DZ 20aug17:
//var isFullDuplex = $('input:radio[name=print_summary_duplex]').filter(":checked").val() == 'duplex';
var isFullDuplex = $('#chk_duplex_supported').prop('checked');
//$('#btn_finish_cards_sumbit_print').attr('data-next-step', isFullDuplex ? "#print-two-sided" : "#print-first-side")
console.log('updated next step to', isFullDuplex ? "#print-two-sided" : "#print-first-side");
$('#btn_finish_cards_sumbit_print').data('next-step', isFullDuplex ? "#print-two-sided" : "#print-first-side");
};
//DZ 11sep17: splitting to new method (used to exist only for invitations modal):
bind_send_online_finish_tab();
//auto setting preview laoyout (a4/ltr,sizes, duplex) for popup controls (DZ 17aug17: only for sizes now)
$('.print-options input[type="radio"]').change(desLogic.func_update_preview_panel);
//DZ 17aug17: new dropdown for a4/ltr:
$('.print-options select').change(desLogic.func_update_preview_panel);
//DZ 20aug17: forgot about this one:
$('#chk_duplex_supported').change(desLogic.func_update_preview_panel);
//DZ 15feb15: square cards have no 'half' size:
//DZ 11sep17: ecards_v2 too
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if ((editorMode == 'cards' || editorMode == 'ecards_v2') && getLayout() == "square") {
if ((editorMode == 'cards' || editorMode == 'ecards') && getLayout() == "square") {
current_print_page_size_mode = "full";
$('#card_size_setting_section').hide();
$('#card_size_setting_section_CLONED').hide();
}
//Download button (from tabs popup):
$('#btn_finish_cards_download').click(function () {
$.publish('designer.download_click', [editorMode]);
if (isIE9)
uxController.open_incompatible_browser_popup();
else {
current_print_page_size_mode = $('input:radio[name=print_summary_card_size]').filter(":checked").val();
//DZ 17aug17:
//current_page_type = $('input:radio[name=print_summary_page_size]').filter(":checked").val();
current_page_type = $('#page_size_dropdown').val();
if (getLayout() == "square")
current_print_page_size_mode = "full";
download_card_as_pdf();
desLogic.mark_as_clean();
desLogic.close_popups_or_drawers();
//thisController.close_all_popups();
}
});
//REDESIGN APPROVED:
//non-duplex popups button actions (popup_print_page_first, popup_print_page_last):
$('#btn_print_non_duplex_first_page').click(function () {
now_loading_start();
current_print_page_size_mode = $('input:radio[name=print_summary_card_size]').filter(":checked").val();
//DZ 17aug17:
//current_page_type = $('input:radio[name=print_summary_page_size]').filter(":checked").val();
current_page_type = $('#page_size_dropdown').val();
//DZ 20aug17: added default_page_size to event reporting
$.publish('designer.print', [editorMode, { 'pageNum': 'page1', 'current_print_page_size_mode': current_print_page_size_mode, 'current_page_type': current_page_type, 'default_page_size': window.default_page_size }]);
if (getLayout() == "square")
current_print_page_size_mode = "full";
print_card(current_print_page_size_mode, 1, function () {
desLogic.mark_as_clean();
now_loading_stop();
//thisController.close_all_popups();
//thisController.show_popup_centered($('#popup_print_page_last'));
});
});
//REDESIGN APPROVED:
$('#btn_print_non_duplex_last_page').click(function () {
desLogic.mark_as_clean();
now_loading_start();
print_card(current_print_page_size_mode, 2, function () {
now_loading_stop();
//thisController.close_all_popups();
desLogic.close_popups_or_drawers();
});
//DZ 20aug17: added default_page_size to event reporting
$.publish('designer.print', [editorMode, { 'pageNum': 'page2', 'current_print_page_size_mode': current_print_page_size_mode, 'current_page_type': current_page_type, 'default_page_size': window.default_page_size }]);
});
//REDESIGN APPROVED:
//print duplex popup: bind the 'print duplex' real button:
$('#btn_print_duplex_from_guide').click(function () {
//print duplex:
desLogic.mark_as_clean();
now_loading_start();
current_print_page_size_mode = $('input:radio[name=print_summary_card_size]').filter(":checked").val();
//DZ 17aug17:
//current_page_type = $('input:radio[name=print_summary_page_size]').filter(":checked").val();
current_page_type = $('#page_size_dropdown').val();
//thisController.close_all_popups();
desLogic.close_popups_or_drawers();
print_card(current_print_page_size_mode, 'duplex', function () {
now_loading_stop();
//thisController.close_all_popups();
// desLogic.close_popups_or_drawers();
//clearing previous generated preview images (to clear mem)
$('.print_summary_preview img.generated_preview_page').remove();
});
//DZ 20aug17: added default_page_size to event reporting
$.publish('designer.print', [editorMode, { 'pageNum': 'duplex', 'current_print_page_size_mode': current_print_page_size_mode, 'current_page_type': current_page_type, 'default_page_size': window.default_page_size }]);
});
//init print duplex popup: (shown with desLogic.show_duplex_guide_popup)
//show only browser specific html:
var OSName = getOSName();
var isMac = (OSName == "MacOS");
var isWindows = (OSName == "Windows");
var isAndroid = navigator.userAgent.indexOf("Android") > 0;
var isChrome = sayswho().toLowerCase().indexOf("chrome") >= 0;
var isSafariTablet = (sayswho().toLowerCase().indexOf("safari") >= 0) && (browser_category == 'tablet' || browser_category == 'mobile');
var isSafariDesktop = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
var isFirefox = (sayswho().toLowerCase().indexOf("firefox") >= 0);
//var isIE = (sayswho().toLowerCase().indexOf("ie") == 0);
//var isIE9 = sayswho() == "MSIE 9";
var specific_browser_suffix = null;
if (isAndroid) specific_browser_suffix = "android";
else if (isChrome) specific_browser_suffix = "chrome";
else if (isSafariTablet) specific_browser_suffix = "ipad";
else if (isMac && isFirefox) specific_browser_suffix = "mac_firefox";
else if (isMac) specific_browser_suffix = "mac_safari";
else if (isWindows) specific_browser_suffix = "windows";
//$('#popup_print_duplex_guide .browser_specific').hide();
//$('#popup_print_duplex_guide .browser_specific.bs_' + specific_browser_suffix).show();
$('#popup_finish_tabs_cards .browser_specific').hide();
$('#popup_finish_tabs_cards .browser_specific.bs_' + specific_browser_suffix).show();
//DZ 13aug17: setting default a4/letter:
window.default_page_size = 'letter';
if (typeof countryCode === "undefined" || countryCode == null || countryCode == '')
console.log("A4/LETTER detection: no country code (probably DEV/Local env)");
else {
var searchTermsForLetter = [
'US', ..\\http\\usa\\MS_7807.html
'USM', ..\\http\\MS_7808.html
'CA', ..\\http\\canada\\MS_7809.html
'MX', ..\\http\\mexico\\MS_7810.html
'DO', ..\\http\\dominican republic\\MS_7811.html
'PH', ..\\http\\philipines\\MS_7812.html
'CL', ..\\http\\chile\\MS_7813.html];
var shouldBeLetter = searchTermsForLetter.indexOf(countryCode.toUpperCase()) > -1;
if (!shouldBeLetter) {
//DZ 17aug17: moving from radios to dropdown for a4/letter:
//$('input:radio[name=print_summary_page_size],input:radio[name=print_summary_page_size_CLONED]').filter('[value="a4"]').prop("checked", true);
$('#page_size_dropdown,#page_size_dropdown_CLONED').val('a4').trigger('change.select2');
window.default_page_size = 'a4';
}
console.log("A4/LETTER detection: " + (shouldBeLetter ? 'Letter' : 'A4'), countryCode);
}
//DZ 17aug17: bind duplex tooltip:
if ($().qtip) {
$('.tooltip-mark').qtip({
show: { event: 'mouseenter touchstart' },
content: {
text: $('#popup_finish_tabs_cards .tooltip-content')
},
position: {
my: 'center right',
at: 'center left',
viewport: $(window),
adjust: {
method: 'flip flip'
}
},
style: {
classes: 'tooltip-simple',
tip: {
border: false,
width: 16,
height: 8
}
}
});
}
};
//private
//YZ 17-NOV-15: adding text with actual size below dialog buttons
function setInviteLayoutDimensions() {
//DZ 9aug17: fixing dimension texts - removing '
//var dimensions = { "portrait": { "1": "7.7' X 11'", "2": "5' X 7'", "4": "3.5' X 5'" }, "landscape": { "1": "11' X 7.7'", "2": "7' X 5'", "4": "5' X 3.5'" }, "square": { "1": "8.5' X 8.5'", "2": "5' X 5'", "4": "" } };
var dimensions = { "portrait": { "1": "7.7 X 11", "2": "5 X 7", "4": "3.5 X 5" }, "landscape": { "1": "11 X 7.7", "2": "7 X 5", "4": "5 X 3.5" }, "square": { "1": "8.5 X 8.5", "2": "5 X 5", "4": "" } };
var layout = getLayout();
//DZ 22jan17: redesign
//$('#popup_invitations_per_page a[num_per_page]').each(function () {
// var invites_num = $(this).attr('num_per_page');
// $('.txt_invite_size', this).html(dimensions[layout][invites_num]);
//})
$('#popup_finish_tabs .layout-options li[num_per_page]').each(function () {
var invites_num = $(this).attr('num_per_page');
$('.option-size', this).html(dimensions[layout][invites_num]);
});
}
//PRIVATE - gets array of 'tags' = email addresses
function get_emails_tags() {
if (!inMobileMode)
return $('#send_form_email_to').tagEditor('getTags')[0].tags;
else {
//in mobile we have a simple textarea
var emails = $('#send_form_email_to').val().split(/(?:,| |;)+/);
//removing empty entries
emails = $.grep(emails, function (n) { return n == 0 || n });
return emails;
}
}
//PRIVATE - sets events for the 'send ecard' thing again
function bind_send_online_events() {
//ENVELOPE ThankYou SCREEN:
$('#ecard_send_card_again').click(function () {
//back to form, clear texts, show popup:
//$('#ecards_thank_you_section').hide();
//thisController.close_all_popups();
desLogic.close_popups_or_drawers();
//same popup for invi & ecards:
if (!inMobileMode) {
var tags = get_emails_tags(); //$('#send_form_email_to').tagEditor('getTags')[0].tags;
for (i = 0; i < tags.length; i++) {
$('#send_form_email_to').tagEditor('removeTag', tags[i]);
}
}
else {
$('#send_form_email_to').val('');
}
//$('#send_form_email_to').val('');
//$('#send_form_name_form').val('');
//thisController.show_popup_centered($('#popup_ecard_send'));
//DZ 4jan17: not 'popup_finish_tabs', should be 'popup_finish_tabs_cards'
if (inMobileMode) {
//$('#popup_finish_tabs').modal('show');
$('#popup_finish_tabs_cards').modal('show');
}
else
//uxController.show_popup_centered($('#popup_finish_tabs'));
uxController.show_popup_centered($('#popup_finish_tabs_cards'));
});
//YZ 7/8/17 - adding mailcheck validation to sender email
$('#send_form_email_from').on('blur', function () {
$(this).mailcheck({
suggested: function (element, suggestion) {
$(element).val(confirm('Did you mean ' + suggestion.full + ' ?') ? suggestion.full : $(element).val());
}
})
});
//extend query validator with "mulltiemail" field
jQuery.validator.addMethod(
"multiemail",
function (value, element) {
try {
var already_erred = false;
if (this.optional(element)) // return true on optional element
return true;
var emails = value.split(/[;, \n]+/); // split element by , and ;
valid = true;
for (var i in emails) {
value = emails[i];
//accepting empty strings
valid = valid && (jQuery.validator.methods.email.call(this, $.trim(value), element) || $.trim(value) == '');
if (!already_erred)
if (!valid) {
already_erred = true;
debug.warn('invalid email "' + value + '"');
}
else
debug.log('valid email: "' + value + '"');
}
return valid;
}
catch (e) {
debug.error('validator exception', e);
}
return false;
},
jQuery.validator.messages.email
);
//submitting the email form to server
//DZ 24sep17: now this gets urlArray
function submit_to_server(urlArray) {
return $.ajax({
method: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: '..\\Card\\Submit.html',
data: JSON.stringify({
SenderName: $('#send_form_name').val(),
SenderEmail: $('#send_form_email_from').val(),
RecipientsEmails: $('#send_form_email_to').val(),
//SendMeCopy: $('#send_form_chk_send_copy:checked').length > 0,
PickUpNotification: $('#send_form_chk_let_me_know:checked').length > 0,
ShowFaceBookComments: $('#send_form_chk_comments:checked').length > 0,
//DZ 3oct18: [SAM-49]
//AllowGifts: $('#send_form_chk_gifts:checked').length > 0,
//DZ 5sep18: code merge with web/SAM - not sure this exists on SAM:
ShowRecipientList: $('#send_form_chk_recipientlist').length ? $('#send_form_chk_recipientlist:checked').length > 0 : null,
ImageName: urlArray,
EcardId: cardConfig.id,
SectionId: sectionId,
RegistryLinkName: !$('#send_form_chk_registrylink:checked').length
? null
: $('#send_form_registry_name').val(),
RegistryLinkUrl: !$('#send_form_chk_registrylink:checked').length
? null
: $('#send_form_registry_url').val(),
Recaptcha: $('#g-recaptcha-response').val()
}),
error: ajax_show_error_popup_handler //shows error popup
});
}
function show_thank_you(submit_rep) {
//show thank you envelope screen
//If current language is spanish the URL should have /es at the end:
var url_server = submit_rep.url;
//if (currentCulture == "es")
// url_server += "/es";
$('#ecard_see_card').attr('href', url_server);
$('.ecard_not_sent').hide();
$('.ecard_not_sent_list').html('');
now_loading_stop();
desLogic.close_popups_or_drawers();
if (inMobileMode)
$('#popup_thanks_for_sending').modal('show');
else
uxController.show_popup_centered($('#popup_thanks_for_sending'));
//Clearing recipient list
if (!inMobileMode) {
var tags = $('#send_form_email_to').tagEditor('getTags')[0].tags;
for (i = 0; i < tags.length; i++) { $('#send_form_email_to').tagEditor('removeTag', tags[i]); }
}
else {
$('#send_form_email_to').val('');
}
}
var submitFunction;
//DZ 24sep17: reworked this entrie area:
submitFunction = function (form) {
$.publish('designer.send', [editorMode, 'email']);
now_loading_start();
desLogic.preview3d_detect_and_upload_modified_pages_previews('upload', function (pagesPreviewUrlsArray) {
if (editorMode == 'invitations')
$(".decor_watermark").hide();
submit_to_server(pagesPreviewUrlsArray).done(function (submit_rep) {
if (!submit_rep.d) {
$('#send_form_error').html(submit_rep.m).show();
if (submit_rep.r == "Captcha") {
$('#send_form_captcha').html('').show();
loadCaptcha('send_form_captcha');
}
now_loading_stop();
} else {
show_thank_you(submit_rep);
}
});
});
return false;
};
//var authSubmitFunction = function (form) {
// //authenticate().done(function (d) {
// // var authd = d;
// // authd.withoutrefresh = true;
// // afterauth.resolve(authd);
// //DZ 27sep17: temporary check
// //if (!$('#send_form_email_to').tagEditor('getTags')[0].tags || $('#send_form_email_to').tagEditor('getTags')[0].tags.length == 0)
// // {
// // alert("STOP EVERYTHING - tried to commit invalidated form");
// // console.error("STOP EVERYTHING - tried to commit invalidated form", $('#send_form_email_to').tagEditor('getTags')[0].tags);
// // return;
// // }
// submitFunction(form);
// //});
//};
var form = $('#ecard_send_form');
$('#send_form_send_btn').click(function (e) {
e.preventDefault();
if (sectionId == '3') {//invitations
authenticate(true).done(function (d) {
var authd = d;
authd.withoutrefresh = true;
afterauth.resolve(authd);
form.submit();
});
} else {
form.submit();
}
});
form.validate({
rules: {
send_form_name_from: {
required: true,
minlength: 2
},
send_form_email_from: {
required: true,
minlength: 2,
email: true
},
send_form_email_to: {
required: true,
//minlength: 2,
multiemail: true
},
send_form_registry_url: //only for online invites
{
required: true,
url: true
}
},
messages: {
send_form_name_from: {
required: "Please enter your name",
minlength: "Your name must consist of at least 2 characters"
},
send_form_email_from: {
required: "Please enter your email",
minlength: "Your email must consist of at least 2 characters",
email: "Please enter a valid email address"
},
send_form_email_to: {
required: "Please enter email addresses, separated by commas.",
multiemail: inMobileMode ? 'Some email addresses are invalid.' : "Please fix or remove the red labeled addresses."
..\\http\\minlength\\MS_7814.html "Your password must be at least 5 characters long"
}
},
//if all OK:
submitHandler: submitFunction
});
};
//public - this is not called from SAM - only web
this.saveEcardDetails = function (ecard, urlArray) {
return $.ajax({
type: 'POST',
url pageArgSaveEcard, \\MS_7815.html'@Url.Action("SaveEcardDetails")',
//data: { ecard: ecard, image: image, sectionId: sectionId },
//data: { ecard: ecard, image: urlArray, sectionId: sectionId },
data: JSON.stringify({ ecard: ecard, image: urlArray, sectionId: sectionId }),
dataType: 'json',
contentType: "application/json; charset=utf-8",
async: false,
error: ajax_show_error_popup_handler
});
};
//DZ 9jan18: fixing DC-125
//public
//this.facebookPopup = function (url) {
// //var sharer = "..\\https\\www.facebook.com\\sharer\\MS_7816.html" + url + '@(Culture.Name == "en" ? "" : ("..\\index.html" + Culture.Name))';
// var sharer = "..\\https\\www.facebook.com\\sharer\\MS_7816.html" + url + (pageArgCultureName == "en" ? "" : "..\\index.html" + pageArgCultureName);
// window.open(sharer, 'sharer', 'width=626,height=436');
//};
//private:
function upload_file_to_s3(file, s3config, expiryDate, filename, contentType, succFunc2, errorFunc2) {
//NEW CODE - upload to S3:
debug.log('uploading to s3');
try {
AWS.config.update({
accessKeyId: s3config.AwsKey,
secretAccessKey: s3config.AwsSecret
});
AWS.config.region = s3config.Region;
var bucket = new AWS.S3({ params: { Bucket: s3config.BucketName } });
var params = {
Key: filename,
ContentType: contentType,
//ContentEncoding: 'base64',
ContentDisposition: 'attachment',
Body: file,
ServerSideEncryption: 'AES256'
};
if (expiryDate != null)
params.Expires = expiryDate;
bucket.putObject(params, function (err, data) {
if (err) {
// There Was An Error With Your S3 Config
console.error("failed to upload to s3", err);
if (errorFunc2)
errorFunc2(err);
//throw err;
}
else {
// Success!
//return final URL - "https://s3.amazonaws.com/testcalendars.images.greetingsisland.com/dev563/fece24e6.jpeg";
var finalUrl = "..\\https\\s3.amazonaws.com\\MS_7817.html" + s3config.BucketName + '..\\index.html' + filename;
// console.log('upload to s3 success', finalUrl);
succFunc2(finalUrl);
}
});
}
catch (exxxx) {
console.error('error', exxxx);
if (errorFunc2)
errorFunc2(exxxx);
}
}
//public
this.upload_temp_file_to_s3 = function (file, filename, contentType, succFunc, errFunc) {
getTempS3BucketInfo().then(function (s3config) {
//var expiryDate = new Date();
//expiryDate.setDate(expiryDate.getDate() + 1); //1 more day to expire
upload_file_to_s3(file, s3config, null, filename, contentType, succFunc, errFunc);
});
};
//private:
//YZ 3/9/18 - adding parameter saveMode to allow different behaviour in different scenarios. Possible values: "save_draft", "online_invitation"
function saveCard(saveName, cardDesign, imagesUrls) {
return $.post(pageArgSaveCard, {
userCardCode: draftCardCode || userCardCode, //save as draft if draft exists
cardId: cardId,
sectionId: sectionId,
cardDesign: JSON.stringify(cardDesign),
saveName: $("").html(saveName).text(),
imageUrls: imagesUrls
});
};
//private:
function getTempS3BucketInfo() {
var response = new $.Deferred();
$.ajax({
type: 'POST',
url: '..\\Card\\GetTempStorageConfig.html',
}).done(function (d) { response.resolve(JSON.parse(decString(d.key, d.value))) });
return response;
}
//private:
function upload_ecard_image(img_base64) {
var fixed_img_base64 = img_base64.replace('data:image/jpeg;base64,', '');
//NOT ASYNC: so facebook popup wont be blocked.
debug.log('submitting image to server');
var server_url = (editorAppMode === "SAM") ? api_base_url : '';
return $.ajax({
type: 'POST',
..\\http\\dz 11mar18 sam code merge \\DZ 8jan18\\MS_7818.html) added api_base_url
//url: '/Card/SaveEcardImage',
url: server_url + '/Card/SaveEcardImage',
data: { base64String: fixed_img_base64, sectionId: sectionId },
async: false,
//error: ajax_show_error_popup_handler, //shows error popup
//DZ 1jul18: adding reporting for SAM API calls
error: function (a, b, c) {
ajax_show_error_popup_handler(a, b, c);
if (editorAppMode === 'SAM') {
try {
SAMLogic.sendAnalErrorFromJS('..\\Card\\SaveEcardImage.html');
}
catch (eee) { console.error('sendAnalErrorFromJS failed', eee); }
}
}
});
}
//public:
//YZ19oct15: returning the dimensions of the rendered image, according to layout
//default width for portrait = 3750, iOS = 3000
this.getOrderRenderDimensions = function (renderDimension) {
var default_size;
switch (renderDimension) {
case renderDimensions.sample: //for after an order complete
default_size = 625;
break;
case renderDimensions.preview: //for pixter preview
default_size = 500;
break;
case renderDimensions.thumbnail: //for saved invites email
default_size = 300;
break;
case renderDimensions.einvitation: //for online invite
default_size = 750;
break;
default:
default_size = 3750;
if (isIOS())
default_size = 3000;
}
var canvasH;
var canvasW;
if (getLayout() === 'landscape') {
//YZ10oct15: default width is 3750
var widthRatio = ($('.editorFrame').width() / $('.editorFrame').height());
canvasH = getParameterByName('width') === '' ? default_size : getParameterByName('width');
canvasW = parseInt(canvasH * widthRatio);
}
else {
//YZ10oct15: default height is 3750
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
canvasW = getParameterByName('width') === '' ? default_size : getParameterByName('width');
canvasH = parseInt(canvasW * heightRatio);
}
return { 'width': canvasW, 'height': canvasH };
}
//captcha stuff:
var rcaptcha = null;
function loadCaptcha(container) {
if (rcaptcha != null) {
grecaptcha.reset(rcaptcha);
} else {
rcaptcha = grecaptcha.render(container, {
'sitekey' pageArgRecaptchaPKey \\MS_7819.html '@Settings.RecaptchaPublicKey'
});
}
};
function initRecipientsEditor() {
//YZ 7/3/17 - not needed in admin, therefore skipping
if (is_admin_mode)
return;
//This will change text area into a tags list using tagEditor plugin
//Will also check validity of email addresses, and check for typos
var TXT_EMAILS_PLACEHOLDER = 'Enter email addresses separated by commas';
if (!inMobileMode) {
var REGEX_EMAIL = '([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@' +
'(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)';
send_form_tag_editor = $("#send_form_email_to").tagEditor({
delimiter: ', ', /* space and comma */
removeDuplicates: false, //due to bug in tagEditor plugin
placeholder: TXT_EMAILS_PLACEHOLDER,
onChange: function (field, editor, tags) { //go over all email addresses and add 'warning' class for each invalid address
$(editor).find("li").each(function (index) {
var email_address = $(this, "div.tag-editor-tag").text();
var email_elements = $(this).find("div.tag-editor-tag , div.tag-editor-delete");
if (email_address != '' & email_address.match(REGEX_EMAIL) == null) {
email_elements.addClass("warning");
}
else if (email_address.match(REGEX_EMAIL) != null) {
email_elements.removeClass("warning");
}
})
},
beforeTagSave: function (field, editor, tags, tag, val) {
var correct_val = val;
//This will check if there is a fix suggestion for email address
Mailcheck.run({
email: val,
suggested: function (suggestion) {
//In case there is a suggeted fix - ask user
correct_val = confirm('Did you mean ' + suggestion.full + ' ?') ? suggestion.full : correct_val;
},
empty: function (element) {
}
});
return correct_val;
}
});
$(".tag-editor").addClass('custom_scrollbar');
}
else {
$('#send_form_email_to').attr('placeholder', TXT_EMAILS_PLACEHOLDER);
}
}
//public
//DZ 5jan17: maybe this was called reposition_corner_handle_if_needed sometime in the past (referenced from other code)
//DZ 29sep14: this method makes sure a movable element's handle isnt out of bounds
//used for "delete" handle for stickers and movalbe-textslots
//for lower,left corner handle:
this.reposition_sticky_handles = function (jqMovable) {
//console.log('reposition_sticky_handles', jqMovable);
//parent container:
var jqContainer = jqMovable.parents('.editorFrame:first');
//movable properties:
var jqMovable_left = parseFloat(jqMovable.css('left').replace('px', ''));
var jqMovable_top = parseFloat(jqMovable.css('top').replace('px', ''));
//each handle:
var handles = jqMovable.find('[sticky_handle]');
handles.each(function () {
var jqHandle = $(this);
var handle_side = $(this).attr('sticky_handle');
var half_handle_width = (jqHandle.width() / 2); //used instead of static css values.
var half_handle_height = (jqHandle.height() / 2); //used instead of static css values.
//handle position relative to container, including offset for handle size:
var handle_x =
jqMovable_left + //starting point for movable
(handle_side[1] == "w" ? 0 : jqMovable.width()) - //edge (left or right)
half_handle_width;//offset for handle button
var handle_y =
jqMovable_top + //starting point for movable
(handle_side[1] == "n" ? 0 : jqMovable.height()) - //edge (left or right)
half_handle_height;//offset for handle button
//X fixes:
if (handle_side[1] == "w") {
//west (shouldnt exceed left 0):
var newLeft;
if (handle_x > 0)
newLeft = -half_handle_width;
else
//DZ 22may17: dont even know why, in mobile need to add more
newLeft = -jqMovable_left + (inMobileMode ? half_handle_width * 2 : 0);
jqHandle.css('left', newLeft + 'px');
//debug.log('left was ' + handle_x + ' now ' + newLeft);
}
else {
//east (shouldnt exceed right 0)
var newRight;
//DZ 20feb17: fine tuning this shit:
if (handle_x < jqContainer.width() - (2 * half_handle_width))
newRight = -half_handle_width;
else
newRight = jqMovable_left + jqMovable.width() - jqContainer.width();
jqHandle.css('right', newRight + 'px');
//debug.log('RIGHT was ' + handle_x + ' now ' + newRight);
}
//Y fixes:
if (handle_side[0] == "n") {
alert('should never get here. only south corners support');
}
else {
//south (shouldnt exceed bottom 0)
var newBottom;
if (handle_y < jqContainer.height() - half_handle_height)
newBottom = -half_handle_height;
else
newBottom = jqMovable_top + jqMovable.height() - jqContainer.height();
jqHandle.css('bottom', newBottom + 'px');
//debug.log('BOTTOM was ' + handle_y + ' now ' + newBottom);
}
});
}
//public:
//DZ 24dec17: notice saveImage is overridden on SAM
this.saveImage = function (base64img, saveImageType, response, tried) {
var _saveImageType = saveImageType !== undefined ? saveImageType : 'CardUserPhoto';
response = response || new $.Deferred();
tried = tried || 0;
var data = {
code: userCardCode,
type: _saveImageType,
base64img: base64img,
};
data[settings.tokenName] = settings.token;
$.post(settings.baseUrl + '..\\card\\saveimage.html', data)
.done(function (ret) {
if (ret.error == 0) {
response.resolve(ret);
} else if (tried >= 2) {
response.reject(ret);
}
else {
desLogic.saveImage(base64img, saveImageType, response, tried + 1)
.done(function (rt) {
response.resolve(rt);
});
}
})
.fail(function (ret) {
if (tried >= 2) {
response.reject(ret);
} else {
desLogic.saveImage(base64img, saveImageType, response, tried + 1)
.done(function (rt) {
response.resolve(rt);
});
}
});
return response.promise();
};
this.SaveImageForOnlineInvitation = function (img, saveImageType) {
//YZ 28/1/19 - adding conversion to base64 (if image is url), this is because afer 'save draft' image src is updated from base64 to URL, then clicking 'send online' will fail because it expect base64
var _saveImageType = saveImageType !== undefined ? saveImageType : 'CardUserPhoto';
var isBase64 = img.length > 200 && img.substring(0, 49).indexOf(';base64') > 0;
var response = new $.Deferred();
var save = function (img, _saveImageType , response, tried) {
response = response || new $.Deferred();
tried = tried || 0;
var data = {
type: _saveImageType,
Base64Img: img
};
data[settings.tokenName] = settings.token;
$.post(settings.baseUrl + '..\\invite\\saveimage.html', data)
.done(function (ret) {
if (ret.error === 0) {
response.resolve(ret);
} else if (tried >= 2) {
response.reject(ret);
}
else {
save(img, saveImageType, response, tried + 1)
.done(function (rt) {
response.resolve(rt);
});
}
})
.fail(function (ret) {
if (tried >= 2) {
response.reject(ret);
} else {
save(img, saveImageType, response, tried + 1)
.done(function (rt) {
response.resolve(rt);
});
}
});
return response.promise();
};
//YZ 28/1/19 - if URL convret to base64
if (!isBase64) {
return imgUrlToBase64_(img).then(function (b64img) {
return save(b64img, _saveImageType, response).promise();
});
}
else
{
return save(img, _saveImageType, response).promise();
}
};
//DZ 21jan18: removing pixter:
//public - Runs runMarginTextDetection (test text too close to edges) and in case everything is OK, calling printOrder
//this.initProPrint = function () {
// //DZ 29mar16: adding warning, so (admin) users wont replace the saved purcahse by mistake
// //YZ 28/6/17: Warning not shown if reorder param is used to allow reorders
// var justDoIt = function () {
// desLogic.close_popups_or_drawers();
// $.publish('designer.pro_print');
// now_loading_start();
// //this method in in Editor.Render (TODO?)
// runMarginTextDetection(function (jqBadTextSlots) {
// if (jqBadTextSlots == null || jqBadTextSlots.length == 0) //DONT PUT === null (3=), its sometimes undefined as well.
// {
// printOrder();
// }
// else {
// debug.log('bad textslots detected', jqBadTextSlots);
// //init text:
// var texts = '';
// $(jqBadTextSlots).each(function () {
// texts = texts + "" + this.find('textarea').val() + "
"; //+ "
";
// });
// //$('#popup_text_in_margins .exceeding_text').text(jqBadTextSlot.find('textarea').val());
// $('#popup_text_in_margins .exceeding_text').html(texts);
// //init 'fix' button:
// $('#popup_text_in_margins #btn_let_me_fix_text').unbind('click').click(function () {
// desLogic.close_popups_or_drawers();
// jqBadTextSlots[0].click();
// return false;
// });
// if (inMobileMode)
// $('#popup_text_in_margins').modal('show');
// else
// uxController.show_popup_centered($('#popup_text_in_margins'));
// now_loading_stop();
// }
// });
// };
// if (getParameterByName("orderDesignCode") !== "" && getParameterByName("reorder") == "") {
// if (confirm("Doing this will replace the saved pro-print.\nAre you sure?"))
// justDoIt();
// }
// else
// justDoIt();
//}
//DZ 21jan18: pixter removed.
//public - Saving when a user press "pro print"
//this.saveCardForPrinting = function (succFunc, failFunc) {
// //IMPORTANT: this method is 2 clones saveUserCard / saveCardForPrinting - make sure to update relevant fixes on both
// //step 1: upload all relevant images to cloud
// //gather all relevant user images:
// var saveResourcesUrls = [];
// var jqPhotoSlotsWithImages = $('.has_photo.slot_photo:not(".invis")');
// //save all resources:
// desLogic.saveUserResourceRecursive("OrderedCardUserPhoto", jqPhotoSlotsWithImages, saveResourcesUrls, 0, function () {
// var savedJson = desLogic.get_export_json("OrderedCardUserPhoto");
// saveOrderDetails(savedJson, saveResourcesUrls\\,optional log\\MS_7820.html).then(succFunc, failFunc);
// }, failFunc);
//};
//DZ 21may17 (18may17 too): new fontsize slider
//var MIN_FONT_SIZE = 13;
var SLIDER_STOP_POSITION = 75; //at this position we start to multiply by 5
this.scaleSliderToFontSize = function (sliderVal) {
//assumptions: slider goes from 0 to 100
//var minTargetVal = 13;
//one stop, at 75, we start accelariting
var newVal = SLIDER_MIN_FONT_SIZE;
if (sliderVal <= SLIDER_STOP_POSITION)
newVal += sliderVal;
else {
newVal += SLIDER_STOP_POSITION + (sliderVal - SLIDER_STOP_POSITION) * 5;
}
return newVal;
}
this.scaleFontSizeToSlider = function (fontSize) {
var sliderPosition;
var STOPPED_Y_POSITION = desLogic.scaleSliderToFontSize(SLIDER_STOP_POSITION);
//we have one break at 75:
if (fontSize <= STOPPED_Y_POSITION)
sliderPosition = fontSize - SLIDER_MIN_FONT_SIZE;
else {
sliderPosition = STOPPED_Y_POSITION - SLIDER_MIN_FONT_SIZE;
var reminder = fontSize - STOPPED_Y_POSITION;
sliderPosition += (reminder) / 5;
}
return sliderPosition;
}
//DZ 24sep17:
//for 3d previews: this method will:
//a. see which of the pages should be uploaded (modified from server version)
//b. render
//c. actionRequired can be: 'upload' - uploads to s3, or just 'render'
//d. return (to callback) with array: {front: URL, left: URL, right: URL, back: URL } - URL will be null if not marked as changed / should be uploaded
this.preview3d_detect_and_upload_modified_pages_previews = function (actionRequired, succFunc) {
//initing return as all unchanged (properties start UpperCase in server side):
var ret = {
Front: null,
Left: null,
Right: null,
Back: null
};
//STEP a: detecting what should be uploaded - marking to-be-uploads in ret
//DZ 24sep17: used for 3d cards preview
var CONST_MARKED_FOR_RENDER_AND_UPLOAD = "MARKED_FOR_RENDER_AND_UPLOAD";
//FIRST PAGE: check if has any text slot, image slot, or sticker
var jqFrameFront = $('.tabFront .editorFrame');
var jqFrameBack = $('.tabBack .editorFrame');
var jqFrameLeft = $('.tabInside .editorFrame:first');
var jqFrameRight = $('.tabInside .editorFrame:last');
//checking if has any EDITABLE content, or stickers:
var hasAnyTextSlots = jqFrameFront.find('.slot_text').length > 0;
var hasAnyImageSlots = jqFrameFront.find('.slot_photo').length > 0;
var hasAnyStickers = jqFrameFront.find('.sticker_container').length > 0;
//setting for later render, or for null if not marked as changed:
//DZ 25sep17: FORCING invitations front to always render
ret.Front = editorMode == 'invitations' || hasAnyTextSlots || hasAnyImageSlots || hasAnyStickers ? CONST_MARKED_FOR_RENDER_AND_UPLOAD : null;
//ALL OTHER PAGES (if exists) - check if has any stickers / non-blank text / non-blank image
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'cards' || editorMode == 'ecards_v2') {
if (editorMode == 'cards' || editorMode == 'ecards') {
//INSIDE pages (left/right/back) - check if has any POPULATED text slot, POPULATED image slot, or sticker
//used in preview3d funcs:
var has_any_edited_content = function (jqFrame) {
//check if has any POPULATED text slot, POPULATED image slot, or sticker
var hasAnyPopulatedTextSlots = false;
jqFrame.find('.slot_text textarea').each(function (idx) {
var thisTextArea = $(this);
//console.log('DETECT_SHOULD_UPLOAD - checking ', thisTextArea, $(thisTextArea).val());
hasAnyPopulatedTextSlots = hasAnyPopulatedTextSlots || $(thisTextArea).val() != '';
});
var hasAnyPopulatedImageSlots = jqFrame.find('.slot_photo.has_photo').length > 0;
var hasAnyStickers = jqFrame.find('.sticker_container').length > 0;
return hasAnyPopulatedTextSlots || hasAnyPopulatedImageSlots || hasAnyStickers;
}
ret.Left = has_any_edited_content(jqFrameLeft) ? CONST_MARKED_FOR_RENDER_AND_UPLOAD : null;
ret.Right = has_any_edited_content(jqFrameRight) ? CONST_MARKED_FOR_RENDER_AND_UPLOAD : null;
ret.Back = has_any_edited_content(jqFrameBack) ? CONST_MARKED_FOR_RENDER_AND_UPLOAD : null;
}
console.log("3D PREVIEWS - finished marking", ret);
//STEP b: rendering & uploading if needed:
var render_and_upload_if_needed = function (pageIdx, jqFrame, localSuccFunc) {
if (ret[pageIdx] != CONST_MARKED_FOR_RENDER_AND_UPLOAD) {
//no need to upload:
//console.log("3D PREVIEWS", pageIdx, null);
localSuccFunc();
}
else {
//RENDER AND UPLOAD:
//render:
var renderWidth = config_render.send_online_width[editorMode.replace("ecards", "cards")][getLayout()]; //config_render["preview3d_" + getLayout()];
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
var renderHeight = parseInt(renderWidth * heightRatio);
//console.log("3D PREVIEWS", pageIdx, "rendering at " + renderWidth + "x" + renderHeight);
render_image_from_frame(jqFrame, renderWidth, renderHeight, function (currentImgData) {
if (actionRequired === 'render') {
ret[pageIdx] = currentImgData;
//LOCAL CALLBACK
localSuccFunc();
}
else {
//(actionRequired == 'upload')
//console.log("3D PREVIEWS", pageIdx, "uploading");
//not async - because FB login might come right after:
upload_ecard_image(currentImgData).done(function (preview_img_url) {
ret[pageIdx] = preview_img_url;
//console.log("3D PREVIEWS", pageIdx, "upload complete");
//LOCAL CALLBACK
localSuccFunc();
});
}
});
}
}
//DZ 7feb18: [CIE-263] - if user paid for invitation watermark removal (from print or download) - share online should also be without watermark
//not validating vs server this time around (to not to mess with FB delays or anything)
var shouldRemoveWaterMark = false;
try {
shouldRemoveWaterMark =
editorMode == 'invitations' &&
getAppFeatureFlag('editor_premium_watermark_feature_enabled') &&
(premium_remove_watermark.initial_state == "PAID" || premium_watermark_removal_was_paid) //premium_watermark_removal_was_paid when user just paid
}
catch (eexxxx) {
console.error("shouldRemove err", eexxxx);
}
//executing the above method for all pages (left,right,back will be null for invitations)
if (shouldRemoveWaterMark) { console.log('WM - hiding'); now_rendering_without_watermark = true; };
//DZ 4apr18: (CIE-276) - several conflicting ways to hide WM were used - shouldRemoveWaterMark (pixter time), $(".decor_watermark").hide() (only UI), isOFBConnected (watermark paid, not sure origin), .decor_watermark.show-watermark-in-preview (?)
//to solve, i've aligned $(".decor_watermark").show/hide() with shouldRemoveWaterMark here
//and then we return to previous vis state
var oldWatermarkVisibility = $('.decor_watermark:visible').length > 0;
if (shouldRemoveWaterMark) $('.decor_watermark').hide(); else $('.decor_watermark').show();
render_and_upload_if_needed('Front', jqFrameFront, function () {
if (shouldRemoveWaterMark) { console.log('WM - reshowing'); now_rendering_without_watermark = false; };
render_and_upload_if_needed('Left', jqFrameLeft, function () {
render_and_upload_if_needed('Right', jqFrameRight, function () {
render_and_upload_if_needed('Back', jqFrameBack, function () {
//console.log("3D PREVIEWS - array ready", ret);
//DZ 4apr18 (cntd.):
if (oldWatermarkVisibility) $('.decor_watermark').show(); else $('.decor_watermark').hide();
succFunc(ret);
});
});
});
});
};
function startSendOnlineV2Flow() {
now_loading_start();
saveOnlineInvitationImages()
.done(function (data) {
var renderWidth = config_render.send_online_width[editorMode][getLayout()];
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
var renderHeight = parseInt(renderWidth * heightRatio);
render_image_from_frame($('.tabFront .editorFrame'), renderWidth, renderHeight, function (currentImgData) {
data.invitationId = onlineInvitation.id;
data.draftCardCode = draftCardCode;
// data.imageLocation = JSON.stringify(pagesPreviewUrlsArray);
submit_online_invitation(data)
.done(function (retSubmitOnline) {
sessionStorage.clear();
sessionStorage.setItem("image" + retSubmitOnline.id, currentImgData);
//DZ 22may18: [OI-4] when we cause navigatation, we might get the "Navigating will erase changes" prompt. here we (hot-)fix this:
window.approved_navigation_datetime = new Date();
//Announcements - skipping to share screen
if (sectionId === '4') {
window.location.href = '..\\invitation\\details\\index.html' + retSubmitOnline.id + '#share';
}
else {
window.location.href = '..\\invitation\\details\\index.html' + retSubmitOnline.id;
}
}).fail(function (err) {
console.error('failedsubmitonilne', err);
// finallyDoThis();
ajax_show_error_popup_handler(null, null, null, '');
});
});
})
.fail(function (err) {
console.error('failed saving', err);
// finallyDoThis();
ajax_show_error_popup_handler(null, null, null, '');
});
}
function submit_online_invitation(data) {
debug.log('submitting submit_online_invitation');
return $.ajax({
type: 'POST',
url: '..\\invite\\Submit.html',
data: data,
//data: { userCardCode: saveCode, onlineInvitationid: onlineInvitation.id, imageLocation: imageLocations, clone:clone },
//async: false,
error: ajax_show_error_popup_handler //shows error popup
});
}
//DZ 21mar18: wrapper class (real logic done in SAM Logic)
//DZ 21mar18: wrapper class (real logic done in SAM Logic)
this.sendTactileEvent = function (eventName) {
try {
if (editorAppMode === 'SAM') {
ionicSendTactileFeedback(eventName)
}
}
catch (tactileEx) {
console.error("tactile error", tactileEx);
}
}
} //END OF DESINGERLOGIC desLogic
//globals:
var isSafariPC = false;
var ua = navigator.userAgent.toLowerCase();
if (sayswho().toLowerCase().indexOf("safari") !== -1 && ua.indexOf("windows") !== -1) {
// Looks like Safari on Windows
isSafariPC = true;
}
function getLayout() {
//override:
var ret = '';
if (getParameterByName("size") != "")
ret = getParameterByName("size");
else {
if (cardConfig == null)
alert('null cardconfig');
else
ret = cardConfig.size;
}
ret = ret.toLowerCase();
if (ret == "wide")
ret = "landscape";
return ret;
}
function now_loading_start() {
$('body').addClass('now_loading');
try {
if (editorAppMode == 'SAM') ionicUpdateIsLoading(true);
}
catch (eee) {
console.error('failed on updating ionicIsLoading', eee)
}
}
function now_loading_stop() {
//TODO: (later) - remove this comment
console.log('-------------------------- NOW LOADING OFF');
$('body').removeClass('now_loading');
try {
if (editorAppMode == 'SAM') ionicUpdateIsLoading(false);
}
catch (eee) {
console.error('failed on updating ionicIsLoading', eee)
}
}
function get_download_filename() {
if (editorMode == 'invitations') return "My Invitation";
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//else if (editorMode == 'ecards') return "My ECard";
//DZ 11sep17:
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//else if (editorMode == 'ecards_v2') return "My ECard";
else if (editorMode == 'ecards') return "My ECard";
else return "My Card";
}
function download_image_helper(base64img, postUserDownloadFunc) {
//DZ 14aug17: ME-131
//a local function to make things more readable
var funcPostDownloadImage = function () {
if (postUserDownloadFunc)
postUserDownloadFunc();
}
//DZ 9aug15: safari desktop doesnt work (suddenly?) with saveAs.
var isSafariDesktop = (sayswho().toLowerCase().indexOf("safari") >= 0) && browser_category == 'desktop';
//first, try to immediately download - not working on IE9, maybe also not in chrome (because of http://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript using b642blob solution for direct download. can use canvas2blob instead, and keep using FileSaver's saveAs (which supports IE9)) :
var isMobile = browser_category == "mobile" || browser_category == "tablet";
if (!isSafariDesktop && !isIE9 && !isMobile && typeof atob === 'function') {
console.log("DIH - first try");
var blob = base64toBlob(base64img.replace('data:image/jpeg;base64,', ''), 'image/jpeg');
saveAs(blob, get_download_filename() + '.jpeg');
funcPostDownloadImage();
return false;
}
//IMPLIED ELSE:
//anther method: showing a button with Download attribute (since adding above saveAs solution this is never accessed)
//checking if there's download support (everything but IE)
var hasDownloadSupport = false;
var a = document.createElement('a');
if (typeof a.download != "undefined")
hasDownloadSupport = true;
//DZ 9aug15: sfari desktop now opens in new window
if (isSafariDesktop) {
console.log("DIH - safdesk mode");
//DZ 22dec16:this is also bad, cannot save page as image. so we upload to s3, in order to download...
//var base64pdf = pdfDoc.output('blob'); //datauristring'); //'data:application/pdf;base64,' + out; // Base64.encode(out);
var blob = base64toBlob(base64img.replace('data:image/jpeg;base64,', ''), 'image/jpeg');
var randomNum = parseInt(Math.random() * 100000000);
var temp_filename = get_download_filename() + "_" + randomNum + ".jpeg";
now_loading_start();
desLogic.upload_temp_file_to_s3(blob, temp_filename, 'image/jpeg', function (newUrl) {
now_loading_stop();
//success method:
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("Download"), getLocCaption("DownloadImageDesc"), getLocCaption("Download"));
$('#popup_simple_button').attr('download', get_download_filename() + ".jpeg").attr('href', newUrl);
uxController.show_popup_centered($('#popup_simple_template'));
//DZ 14aug17: ME-131
$('#popup_simple_button').click(funcPostDownloadImage);
}, function (err) {
//err method
console.error('failed to upload to s3', err);
});
}
else if (hasDownloadSupport) {
console.log("DIH - download support");
if (inMobileMode) {
uxController.bind_simple_drawer("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDesc"), getLocCaption("Download"));
//$('#simple-drawer-button').attr('download', get_download_filename() + ".jpeg").attr('href', base64img);
$("#simple-drawer-button").attr({
//"value": "Download",
"href": URL.createObjectURL(base64toBlob(base64img.replace('data:image/jpeg;base64,', ''), 'image/jpeg')),
"download": get_download_filename() + ".jpeg"
});
//DZ 14aug17: ME-131
$('#simple-drawer-button').click(funcPostDownloadImage);
}
else {
uxController.bind_simple_popup("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDesc"), getLocCaption("Download"));
$('#popup_simple_button').attr('download', get_download_filename() + ".jpeg").attr('href', base64img);
//$('#popup_simple_button').click();
uxController.show_popup_centered($('#popup_simple_template'));
//DZ 14aug17: ME-131
$('#popup_simple_button').click(funcPostDownloadImage);
}
}
else {
console.log("DIH - download not supported ");
//debug.log("download_image_helper: download not supported");
if (inMobileMode) {
//just reporting a DL now, cant really tell when user downloads in this scenario:
funcPostDownloadImage();
uxController.bind_simple_drawer("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDescForMobile"), getLocCaption("Close"));
$('#simple-drawer p').after(
$('
')
.addClass('no_img_download_hotfix')
.attr({ src: base64img })
//.css({ width: 220, height: 'auto', display: 'block', margin: '0 auto 18px auto' })
);
}
else {
//DZ 14aug17: this is not relevant anymore (never reaches this case if mobile)
//if (browser_category == "mobile" || browser_category == "tablet")
// uxController.bind_simple_popup("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDescForMobile"), getLocCaption("Close"));
//else
// uxController.bind_simple_popup("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDescForNoAutoDownload"), getLocCaption("Close"));
//i dont think this (desktop, no download supported) ever happens
uxController.bind_simple_popup("download_image", getLocCaption("DownloadImage"), getLocCaption("DownloadImageDescForNoAutoDownload"), getLocCaption("Close"));
funcPostDownloadImage();
$('#popup_simple_template .content p').after(
$('
')
.attr({ src: base64img })
.css({ width: 220, height: 'auto', display: 'block', margin: '0 auto 18px auto' })
);
uxController.show_popup_centered($('#popup_simple_template'));
}
}
}
//3d config
function init3D(images) {
var wrap = $('._preview_container');
var preview = $('');
wrap.html('');
wrap.append(preview);
preview.load(function () {
preview[0].contentWindow.init3DFrame(images);
});
}
function dispose3D() {
var frame = $('#preview3dFrame');
//frame[0].contentWindow.dispose3DFrame();
frame.remove();
}
;
//controls the UI of the designer
//MOBRED - not 100% finished
function DesktopUXLogic() {
//private
var thisController = this;
//public method:
this.init_editor_desktop_ux = function () {
//DZ 25jun17: scroll event for sticky header on desktop:
//YZ 22/8/18 - removing sticky header
//if (typeof show_sticky_header !== "undefined" && show_sticky_header) {
// $(window).scroll(function () {
// var notification_height = $('#site-notifications').height();
// if (!notification_height) notification_height = 0;
// if (notification_height != 0) notification_height += 20;//adding paddings
// //current scroll:
// var scroll = $(window).scrollTop();
// //tipping point:
// var stickyOffset = $('#editor-desktop').offset().top - notification_height;
// if (scroll >= stickyOffset) {
// $('#editor-toolbar').addClass('fixed').css('margin-top', notification_height + 'px');
// $('#editor-toolbar-container').height($('#editor-toolbar').height() + 20); //20 for padding
// }
// else {
// $('#editor-toolbar').removeClass('fixed').css('margin-top', 0);
// $('#editor-toolbar-container').height('auto');
// }
// });
//}
//DZ 30mar17: TODO: put in CSS, only for IE
//if (sayswho().toLowerCase().indexOf("ie") == 0) {
// $('#loading_overlay span').css({
// 'background': 'none',
http\\MS_24.html 'color': '#02CC90'
// });
//}
//DZ 25jun17: adding support for multiple scales on desktop (freezing to 1):
//DZ 7jul17: that just wasnt a good enough fix
//window.current_autosize_ratio = 1;
//DZ 27mar17: moving shard fonts HTML to its right position
//clone,remove,and re-position (reason: shared HTML, should be in right place in desktop / mobile)
var cloned = $('#editor-fonts').clone();
$('#editor-fonts').remove();
$('#popup_text_style .drop_container').append(cloned);
//Testing buttons for font hotfixes
$('#font_debug_section button').click(function () {
var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
//var canvasW = 1500;
var canvasW = 450;
var canvasH = parseInt(canvasW * heightRatio);
uxController.close_all_popups();
var canvasTarget = $('.editorFrame:visible:first');
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if (editorMode == 'ecards')
// canvasTarget = $('.editorFrame:visible:last');
render_image_from_frame(canvasTarget, canvasW, canvasH, function (img_src) {
$('#font_debug_section img').remove();
$('#font_debug_section').append($('
').attr('src', img_src));
});
});
//DZ 2jan17: adding bindHTML for all andru's stuff in one place - later (TODO) might be better to spread them around the code
//DZ 20mar17: removing this method, putting all inline:
//thisController.bindNewEditorJS();
//DZ 29jan17: hotfixing here. cant have qtip with both click & hover behaviors, so we put a hotfix div above for tooltip, which forwards the click event
//DZ 19feb17: hotfix for tablet
//$('#hotfix_for_sticker_click').mouseup(function () { $("#emoji-add").click(); })
//DZ 9mar17: hotfix for eventName on tablet (used to close finish window before its opened on click)
//var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchend' : 'mouseup';
var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchstart' : 'mouseup';
$('#hotfix_for_sticker_click').on(eventName, function () { $("#emoji-add").click(); });
if ($().qtip) {
$('#emoji-add').each(function () {
$(this).qtip({
content: {
text: $(this).next('.tooltip-content')
},
show: 'click',
//show: {
// delay: 0
//},
hide: {
//when: { event: 'click' },
event: 'click mouseout unfocus',
//leave: true,
fixed: true,
delay: 100
},
position: { my: 'top center', at: 'bottom center' },
style: {
classes: $(this).data('tooltip-class'),
tip: {
corner: 'top center',
border: false,
width: 16,
height: 8
}
}
});
});
$('.text-tooltip').each(function () {
$(this).qtip({
content: {
text: $(this).attr('title')
},
position: {
my: 'top center',
at: 'bottom center'
},
style: {
classes: 'tooltip-simple',
tip: {
corner: 'top center',
border: false,
width: 16,
height: 8
}
}
});
});
$('.text-tooltip-dark').each(function () {
$(this).qtip({
content: {
text: $(this).attr('title')
},
position: {
my: 'top center',
at: 'bottom center'
},
style: {
classes: 'tooltip-simple-dark',
tip: {
corner: 'top center',
border: false,
width: 12,
height: 5
}
}
});
});
}
if (is_admin_mode)
should_have_trash_handle_on_freesize_text_slots = true;
if (browser_category == "mobile" || browser_category == "tablet")
$('body').addClass('tablet_mode');
//this.bind_stickers();
bind_desktop_ux_events();
//this.init_print_summary_popup(); //DZ new 21oct14
//bindFontSelection();
//init popups:
thisController.init_text_design_popup();
//moved to shared:
//thisController.init_image_design_popup();
//IE fix:
PointerEventsPolyfill.initialize({
selector: '.decor_full_image'
});
//DZ 9jul14: hotfix: in IE (IE11 tested) some other jquery fixes 'placeholder' textareas to have value of placeholder. hotfixing here:
$('textarea[placeholder]').each(function () {
var jqTextarea = $(this);
var phText = jqTextarea.attr('placeholder');
if (phText == jqTextarea.val())
jqTextarea.val('');
});
////IE9 obsolete: fix placeholdres (GI used .placeholder() fix that doesnt work with our app)
//if (isIE9)
// fix_ie9_placeholders($('body')); //do it for all existing [placeholder] elements
};
//public - this is executed after entire editor + usersave are loaded
this.post_load_events = function () {
//TODO REMOVE
//if (false) {
// console.warn("AUTO RUNNING FINISH");
// setTimeout(function () {
// $('#btn_combined_finish').click();
// setTimeout(function () {
// $('#btn_open_invitations_diy_popup').click()
// }, 500);
// }, 500);
//}
};
//all page events:
function bind_desktop_ux_events() {
//combo box open:
$('.selected').click(function (e) {
$(this).next('.options').slideToggle('fast');
$(this).toggleClass('now-active');
//to make sure we dont close the stickers dropdown:
e.preventDefault();
e.stopPropagation();
});
$('.close').click(function () {
//DZ: added popup class for closable popups
//$(this).closest('.box').fadeOut();
thisController.hide_popup($(this).parents('.popup'));
});
//$(".tabs ul li").click(function () {
$('body').on('click', '#popup_suggested_msgs .tabs ul li', function (ev) {
// First remove class "active" from currently active tab
$("#popup_suggested_msgs .tabs ul li").removeClass('selected');
// Now add class "active" to the selected/clicked tab
$(this).addClass("selected");
// Hide all tab content
$("#popup_suggested_msgs .tab-content div").hide();
// Here we get the href value of the selected tab
var selected_tab = $(this).find("a").attr("href");
// Show the selected tab content
$(selected_tab).fadeIn();
// At the end, we add return false so that the click on the link is not executed
return false;
});
//front/inside/back tabs:
//DZ 2jan17: redesign
//$('.card_pages_selector li').click(function () {
$('.card_pages_selector a').click(function () {
var tab = $(this).attr('tab');
desLogic.change_editor_tab(tab);
});
//sticker dropdown item click:
//DZ 2jan17 redesigned:
//$('#stickers_dropdown li').click(function () {
//DZ 29jan17: redesigned again:
//$('#stickers_dropdown').change(function () {
$('#stickers_dropdown .options li').click(function (e) {
//var category_id = $(this).attr('category_id');
//var category_id = $(this).val();
var category_id = $(this).attr('value');
$('#stickers_tooltip .options').slideUp('fast');
$('#stickers_tooltip .options').removeClass('now-active');
thisController.bind_stickers_by_category(category_id);
//to make sure we dont close the stickers qtip:
e.preventDefault();
e.stopPropagation();
});
//put sticker from toolbar
$('body').on('click', '#stickers .sticker', (function (ev) {
var sticker_url = $(this).attr('sticker_url');
desLogic.place_sticker_on_designer(sticker_url, $('.editorTab.active .editorFrame:first'), '30%', '30%');
}));
//YZ 26-Jul-17
//Fonts list - close when leaving (with small delay)
$('#popup_text_style .options').mouseleave(function () {
var leave = true;
$(this).off('mouseenter');
$(this).mouseenter(function () { leave = false; });
setTimeout(function () {
if (leave) {
$('#popup_text_style .options').slideUp('fast');
$('#popup_text_style .options').removeClass('now-active');
}
}, 600);
$
});
//PHOTO UPLOAD FLOW:
//show upload popup when clickign photo_slot
//iOS fix. somehow clicks are missed:
var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchend' : 'click';
//DZ REDMOB 28mar17 moved to Shared
//$('body').on(eventName, '.slot_photo', function (ev) {
//...
//});
//edit image_slot properties:
$('body').on('click', '.slot_photo .edit', function (ev) {
var jqSlotPhoto = $(this).parents('.slot_photo');
//if popup already open, and context image is current
if ($('#popup_image_style:visible').length > 0 && jqSlotPhoto.is(desLogic.context_slot_photo))
thisController.close_all_popups();
else
thisController.image_design_popup_open(jqSlotPhoto);
ev.preventDefault();
ev.stopPropagation();
//debug.log(ev);
});
//select upload from computer / facebook\
//SUGGESTED MSG POPUP EVENTS
//open the popup:
$('#btn_show_suggested_msgs').click(function () {
thisController.show_suggested_msgs_popup();
});
//selected message click:
$('body').on('click', '#popup_suggested_msgs .img-content li', function (ev) {
var jqElm = $(this);
debug.log('suggested msg clicked', jqElm);
var suggested_msg = jqElm.text();
desLogic.text_design_popup_current_target.val(suggested_msg);
desLogic.reinit_autosizer(desLogic.text_design_popup_current_target);
desLogic.auto_change_textarea_font_size(desLogic.text_design_popup_current_target);
thisController.close_all_popups();
});
//closing all popups on anything clicked:
var eventName = browser_category == 'tablet' || browser_category == 'mobile' ? 'touchstart' : 'mousedown';
//DZ 8jan17: redesign genclick
//$('body').on(eventName, "#wrapper", thisController.global_click_handler);
$('body').on(eventName, ".site", thisController.global_click_handler);
//focusing out of textbox causes scroll top on tablets:
if (browser_category == "mobile" || browser_category == "tablet") {
$('body').on('focusout', 'textarea', function (ev) {
$('html, body').animate({
//DZ 20feb17: not sure why this specific fix applied, but updating to new redesign elements:
//scrollTop: $(".tool-section:first").offset().top
scrollTop: $(".editor-main:first").offset().top
}, 250);
});
}
if (editorMode == 'invitations')
thisController.bind_invitations_events();
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//else if (editorMode == 'ecards' )
// thisController.bind_ecards_events();
else //if (editorMode == 'cards')
thisController.bind_cards_events();
};
this.global_click_handler = function (ev) {
var jqElm = $(ev.target);
//not clicked inside popup:
if (!jqElm.hasClass('popup') && jqElm.parents('.popup').length == 0) {
//not clicked inside slot_photo:
if (jqElm.hasClass('slot_photo') || jqElm.parents('.slot_photo').length > 0)
return;
if (jqElm.hasClass('slot_text') || jqElm.parents('.slot_text').length > 0)
return;
if (jqElm.hasClass('decor_full_image') || jqElm.parents('.decor_full_image').length > 0)
return;
if (jqElm.is('#loading_overlay') || jqElm.parents('#loading_overlay').length > 0)
return;
//DZ 30apr17: desktop sticker fix - making sure wont de-focus when clicking handle
if (jqElm.is('.ui-resizable-handle'))
return;
if (jqElm.parent().is('.sticker_container_inner'))
return;
debug.log('global gen click', jqElm);
desLogic.reset_focus();
//DZ 23jan18: closing the next pull-down (if opened)
if (jqElm.parents('#finish-button-wrapper').length == 0)
$('#finish-button-wrapper').removeClass('is-open');
if ($('.popup:visible').length > 0) {
//DZ 16jun15: not closing on popup iphone because of asana bug "Printable cards printing menu not working well for mobiles"
//DZ 9mar17: not sure what above comment was about, and if still relevant. commenting condition because of Jira bug "ND-183 mobile: main finish screen hard to close"
//if (browser_category != "mobile") {
debug.log('closing popup from gen click');
thisController.close_all_popups();
//just in case, closing the font dropdown:
$('#popup_text_style .drop_container .options').hide();
$('#popup_text_style .options').removeClass('now-active');
//}
}
}
};
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//not used anymore:
//this.bind_ecards_events = function () {
// //same popup used both for invitations & eCards
// desLogic.bind_finish_tabs_popup();
// //init username/email from cookie (if exists)
// var from_cookie_username = $.cookie("ecard_user_name");
// var from_cookie_useremail = $.cookie("ecard_user_email");
// if (from_cookie_username != null && from_cookie_username != '')
// $('#send_form_name').val(from_cookie_username);
// if (from_cookie_useremail != null && from_cookie_useremail != '')
// $('#send_form_email_from').val(from_cookie_useremail);
//};
this.bind_invitations_events = function () {
$('#btn_add_text').click(desLogic.add_new_text_slot);
//same popup used both for invitations & eCards
desLogic.bind_finish_tabs_popup();
//USER CHOOSES FREE: show free diy popup
//DZ 21jan18: removing pixter
//$('#btn_open_invitations_diy_popup').click(function () {
// thisController.close_all_popups();
// thisController.show_popup_centered($('#popup_finish_tabs'));
//});
//setting layout-specific stuff for invtation finish popups:
//$('#popup_free_or_premium .intro-image').addClass('-' + getLayout());
};
//DZ 23jan17 new method
this.bind_cards_events = function () {
desLogic.bind_cards_finish_tabs_popup();
};
this.hasFileApiSupport = function () {
return !!(window.File && window.FileReader && window.FileList && window.Blob);
};
/* ---- TEXT DESIGN POPUP ---- */
this.init_text_design_popup = function () {
//focusing on textarea brings up the design popup
//DZ 30jun14: moved to init
$('body').on('click', '.slot_text', function () {
$(this).find('textarea').focus();
desLogic.reset_focus();
desLogic.set_focus($(this));
});
//closing the popup: (incl text design logic):
$('.close_this_popup').click(function () {
thisController.close_all_popups();
desLogic.reset_focus();
$('#popup_text_style .options').hide();
$('#popup_text_style .options').removeClass('now-active');
});
//cancel popup:
$('#cancel_text_design_popup').click(function () {
thisController.text_design_popup_revert();
thisController.close_all_popups();
desLogic.reset_focus();
$('#popup_text_style .options').hide();
$('#popup_text_style .options').removeClass('now-active');
return false;
});
$('#cancel_image_design_popup').click(function () {
thisController.image_design_popup_revert();
thisController.close_all_popups();
});
//COLOR - setColorFromUX
$('body').on('change', '#popup_text_style .colors input:radio[name="color"]', function () {
//$('#popup_text_style .colors input:radio[name="color"]').change(function () {
//find label
//DZ 3jan17:
//var label = $('#popup_text_style .colors label[for="' + this.id + '"]');
var label = $('#popup_text_style .colors label[for="' + this.id + '"] span');
//var label = $(this).parent();
var newVal = label.css('background-color');
//set target color:
desLogic.text_design_popup_current_target.css('color', newVal);
//DZ 11jan17: REDESIGN
//desLogic.text_design_popup_current_target.parents('.slot_text').css('outline-color', get_outline_color(newVal));
desLogic.setColorToJQTextSlot(desLogic.text_design_popup_current_target.parents('.slot_text'), newVal);
//DZ 24sep17: was missing!
desLogic.mark_as_dirty();
});
//ALIGN
$('#popup_text_style .align input:radio[name="align"]').change(function () {
var newVal = this.id;
desLogic.text_design_popup_current_target.css('text-align', newVal);
//strange ie9 bug, text-align not being updated. hotfix is re-putting the val inside
//DZ 26jan15: adding IE10 for the fix
var isIE9 = sayswho() == "MSIE 9" || sayswho() == "MSIE 10";
if (isIE9)
desLogic.text_design_popup_current_target.val(desLogic.text_design_popup_current_target.val());
//DZ 24sep17: was missing!
desLogic.mark_as_dirty();
});
//admin only:
//DZ 5feb15: INIT POSITION HELEPRS
if (is_admin_mode) {
//DZ 5feb15: INIT POSITION HELEPRS
$('#admin_text_position_center_h').click(function () {
center_element_in_editor(desLogic.text_design_popup_current_target.parent(), true);
thisController.fix_popup_pos_near_element($('#popup_text_style'), desLogic.text_design_popup_current_target.parent());
});
$('#admin_text_position_center_v').click(function () {
center_element_in_editor(desLogic.text_design_popup_current_target.parent(), false);
thisController.fix_popup_pos_near_element($('#popup_text_style'), desLogic.text_design_popup_current_target.parent());
});
$('#admin_text_position_keycatcher').keydown(function (ev) {
handle_keydown_for_positioning_helper(desLogic.text_design_popup_current_target.parent(), ev);
thisController.fix_popup_pos_near_element($('#popup_text_style'), desLogic.text_design_popup_current_target.parent());
return false;
});
};
};
this.close_all_popups = function () {
//desLogic.text_design_popup_current_target = null;
//$('#popup_text_style').addClass('invis');
this.hide_popup($('.popup'));
};
this.hide_popup = function (jqPopElm) {
jqPopElm.fadeOut(250);
$('#popup_overlay:visible').fadeOut(250);
//DZ 2sep14: fixing overlay issue over stickers: happens on 'back' side of card, on image properties popup
//DZ 25jan17: commented (with another such hotfix - search in file for same comment)
//$('.editor-section').css('z-index', 1);
};
//shows a statis pre-located popup (e.g upload image)
this.show_popup = function (jqPopElm) {
//shouldnt be here!
//thisController.close_all_popups();
//DZ 10aug14: dsiabling fixing dragged icon to appear on top of editor. done also on sticker draggable
//$('.tools-section').css({ 'z-index': 1 });
jqPopElm.fadeIn(250, function () { jqPopElm.removeClass('invis'); });
//REDESIGN:
//if (jqPopElm.parents('#edit-area').length == 0) {
if (jqPopElm.parents('#editor_popups_container').length > 0) {
$('#popup_overlay').fadeIn(250);
}
};
//shows a statis pre-located popup (e.g upload image)
this.show_popup_centered = function (jqPopElm) {
jqPopElm.css({
'margin-left': -jqPopElm.width() / 2 + 'px',
'margin-top': -jqPopElm.height() / 2 + 'px'
});
thisController.show_popup(jqPopElm);
};
//shows a dynamic located popup, dependant of context box, alternating x location, and add arrow in the according place
this.show_popup_near_element = function (jqPopElm, jqContext) {
thisController.close_all_popups();
//y position: middle of jqContext - popup height
thisController.fix_popup_pos_near_element(jqPopElm, jqContext);
//DZ 2sep14: fixing overlay issue over stickers: happens on 'back' side of card, on image properties popup
//DZ 25jan17: commented (with another such hotfix - search in file for same comment)
//$('.editor-section').css('z-index', 100);
jqPopElm.fadeIn(250, function () { jqPopElm.removeClass('invis'); });
};
this.fix_popup_pos_near_element = function (jqPopElm, jqContext) {
//DZ 5jan17: REDESIGN, many changes here
var relativeOffsetTop = jqContext.offset().top - jqContext.parent().parent().parent().offset().top;
//var popup_y = relativeOffsetTop - (jqPopElm.height() / 2) + (jqContext.height() / 2) - 10;
var popup_y = relativeOffsetTop - (jqPopElm.height() / 2) + (jqContext.height() / 2);
//x position: decide if it should be left or right of element
var relativeOffsetLeft = jqContext.offset().left - jqContext.parent().parent().parent().offset().left;
//DZ 5jan17: REDESIGN: changed to fixed 30 - some margins/padding are different then before (used to be 30 in new design- same like padding)
relativeOffsetLeft += 30;
//possible values are: 16, 183, 350 (left side card, only card, right side card)
//var popup_should_open_right_side = relativeOffsetLeft < 300;
var popup_should_open_right_side = relativeOffsetLeft < 330;
//HOTFIX FOR last page's image upload (overriding with static x - forcing opening from right)
if (jqContext.parents('.editorTab.tabBack').length > 0 && jqContext.hasClass('slot_photo'))
popup_should_open_right_side = false;
//DZ 5jan17: forcing invitation text AND IMAge to open from right side in invitation mode
if (editorMode == 'invitations')
popup_should_open_right_side = true;
if (popup_should_open_right_side) {
//opening from the right ([CONTXT] [POPUP])
popup_x = relativeOffsetLeft + jqContext.outerWidth() + 10;
}
else {
//opening from the left: ([POPUP] [CONTXT])
popup_x = relativeOffsetLeft - jqPopElm.outerWidth() - 10;
}
//DZ 12sep16: opening in left side if exceeds window width
//DZ 2jan17: REDESIGN: changed to editor-area - not yet tested at all
//var beginning_offset = parseInt($('.editor-section').position().left);
var beginning_offset = parseInt($('.editor-area').position().left);
//DZ 29jan17: REDESIGN: removed this thing for invitations. not sure why this was needed
//DZ 30mar17: REDEISNG. removed totally
//if (editorMode != 'invitations') {
// //console.log( beginning_offset + popup_x + jqPopElm.width() );
// if (beginning_offset + popup_x + jqPopElm.width() + 138 > $(window).width()) {
// //changing to left side:
// //console.log('changing to left side');
// popup_should_open_right_side = false;
// popup_x = -210;
// }
//}
//debug.error('relative=' + relativeOffsetLeft, popup_should_open_right_side, popup_x);
//setting mix/max values:
//if (popup_x < -10) popup_x = -10;
//fixing only for freesize, so position right only for first page
//setting mix/max values (mainly for freetext slots that can escape boundaries)
//DZ post-REDESIGN 20apr17: (CIE-187) this fixes positioning for landscape cards (big position issue) and portrait carts (minor 10px issue)
var margin_fix = 0;
if (!isNaN($('.editorTab.active').css('margin-left').replace('px', ''))) {
margin_fix = parseFloat($('.editorTab.active').css('margin-left').replace('px', ''));
}
popup_x += margin_fix;
var arrow_pos_fix_diff = 0;
if (!is_admin_mode) {
var editorBoxLeft = $('.editorFrame:visible:first').position().left;
//DZ REDEISGN 30mar17: removed...
//DZ post-REDESIGN 20apr17: uncommenting - working it out better. bug happened in landscape mode, because of margin of container. fixed by popup_x margin_fixing above
if (popup_x > editorBoxLeft + $('.editorFrameContainer:visible:first').width() + 10)
popup_x = editorBoxLeft + $('.editorFrameContainer:visible:first').width() + 10;
if (popup_y > $('.editorFrameContainer:visible:first').height() - jqPopElm.height() - 10) {
var t = popup_y;
popup_y = $('.editorFrameContainer:visible:first').height() - jqPopElm.height() - 10;
arrow_pos_fix_diff = t - popup_y;
if (arrow_pos_fix_diff > 140) arrow_pos_fix_diff = 140;
}
}
//DZ 5jan17: REDESIGN - i dont think these are needed anymore
//HOTIFX for move_handle (shown on tablets), making sure text deisng popup doesnt overlap the move handle
if (should_have_move_handle_on_freesize_text_slots && jqPopElm.attr('id') == 'popup_text_style')
popup_x += 10;
//var containerMarginLeft = parseInt(jqContext.parents('.editorTab').css('margin-left'));
//if (!isNaN(containerMarginLeft)) {
// popup_x += containerMarginLeft;
//}
//DZ 30mar17: .layout_landscape .editorTab.tabFront
//DZ 11sep17: ecards_v2
//DZ 20nov17: migrating from 'ecards v2' to 'ecards' (losing old behavior)
//if ((editorMode == 'cards' || editorMode == 'ecards_v2') && getLayout() == 'landscape' && jqContext.parents('.editorTab.tabInside').length == 0) {
if ((editorMode == 'cards' || editorMode == 'ecards') && getLayout() == 'landscape' && jqContext.parents('.editorTab.tabInside').length == 0) {
popup_y += parseInt($('.editorTab.tabBack').css('margin-top').replace('px', ''));
}
jqPopElm.css({
left: popup_x + 'px',
top: popup_y + 'px'
});
jqPopElm.find('.pu_side_arrow').remove();
var arrowElm = $('');
if (popup_should_open_right_side) arrowElm.addClass('left');
//freetext arrow fixes:
if (jqContext.hasClass('freesize')) {
arrowElm.css({ 'margin-top': (-5 + arrow_pos_fix_diff) + 'px' });
//arrowElm.css({ 'margin-top': (9 + arrow_pos_fix_diff) + 'px' });
}
else
arrowElm.css({ 'margin-top': (-14 + arrow_pos_fix_diff) + 'px' });
jqPopElm.append(arrowElm);
};
this.text_design_popup_open = function (jqInputElement) {
//making sure opening only once, and not receiving multiple focus events
if (!jqInputElement.is(desLogic.text_design_popup_current_target) || $('#popup_text_style:visible').length == 0) {
debug.log('opening the text design popup');
thisController.close_all_popups();
//default = no colors
$('#more_colors').hide();
//saving target for usage:
desLogic.text_design_popup_current_target = jqInputElement;
var jqSlot = jqInputElement.parents('.slot_text:first');
//saving current params if user cancels
desLogic.text_design_popup_revert_data = thisController.get_text_design_params_from_desiger(jqInputElement);
//bind popup control's for existing data:
//font size
var currentSize = jqInputElement.css('font-size').replace('px', '');
//$('#slider_fontsize').slider({ value: currentSize });
$('#slider_fontsize').slider({ value: desLogic.scaleFontSizeToSlider(currentSize) });
//color:
var currentColor = jqInputElement.css('color');
var currentColorPresetExisting = false; //sometimes pre-set colors dont exist in our color options
$('#popup_text_style .colors label span').each(function () {
if ($(this).css('background-color') == currentColor || $(this).css('background-color') == rgb2hex(currentColor)) {
//find relevant radio button and click it
$('#popup_text_style .colors input[id="' + $(this).parent().attr('for') + '"]').prop('checked', true);
currentColorPresetExisting = true;
}
});
if (!currentColorPresetExisting) {
$('#popup_text_style .colors input[type="radio"]').prop('checked', false);
}
//current alignment
var currentAlign = jqInputElement.css('text-align');
$('#popup_text_style .align input[id="' + currentAlign + '"]').prop('checked', true);
//font:
var currentFont = jqInputElement.css('font-family');
var fontSize;
//now we find the right caption for this font, as included inside the font dropdown
var fontFixedName = strreplace(strreplace(currentFont.toLowerCase(), '"', ""), "'", "");
var currentFontCaption = null;
$('#popup_text_style .drop_container ul.options li span').each(function () {
var optCaption = $(this).text();
//if (fontFixedName == optCaption.toLowerCase())
var fixed_option_font = strreplace(strreplace($(this).css('font-family').toLowerCase(), '"', ""), "'", '');
//debug.log(fontFixedName, fixed_option_font);
if (fontFixedName == fixed_option_font) {
currentFontCaption = optCaption;
fontSize = $(this).css('font-size');
//DZ 12jan17: active style to selected font
$('#popup_text_style .custom_scroll li.active').removeClass('active');
$(this).parent().addClass('active');
}
});
if (currentFontCaption == null) debug.error('error - couldnt find font "' + currentFont + '" in font options');
//DZ 10feb16: so much trouble in this single line. caused IE11 issues with font loading: wrong font name loaded (because of toLower), and the right was not in cache. caused issue when 1. opening textdesign 2. rendering 3. Times New Roman instead of Cougrette (url: http://www.greetingsisland.com/design/invitations/balloon-dogs/314-7735?debugconsole=1)
//$('#popup_text_style .selected p').empty().append($('
').css('font-family', currentFont).text(currentFontCaption));
$('#popup_text_style .selected p').empty();
//DZ 15feb16: order affecting here:
//$('#popup_text_style .selected p').append($('').css('font-family', getFontName(jqInputElement.css('font-family'))).text(currentFontCaption));
//DZ 31mar16: making this step by step, solves an IE issue with Times New Roman on 6 fonts: Learning Curve, Patrick Hand, Jennasue, alex brush, luckiest guy, vast shadow
//DZ 31mar16: real problem was in setting new fonts, but appyling here just in case
//$('#popup_text_style .selected p').append($('').text(currentFontCaption).css('font-family', getFontName(jqInputElement.css('font-family'))));
$('#popup_text_style .selected p').append($(''));
$('#popup_text_style .selected p span').text(currentFontCaption);
$('#popup_text_style .selected p span').css('font-family', getFontName(jqInputElement.css('font-family')));
$('#popup_text_style .selected p span').css('font-size', fontSize);
//DZ 17aug14: hiding suggested msgs for small textareas
//notice: they're hidden in CSS levl for invitations
var suggested_msgs_shown = true;
if (is_admin_mode)
suggested_msgs_shown = false;
else
if (!jqSlot.hasClass('freesize')) {
//if less than 40% slot_text then dont allow suggested messages.
var height_perc = 100 * jqSlot.outerHeight() / jqSlot.parent().outerHeight()
if (height_perc < 33)
suggested_msgs_shown = false;
}
//$('#btn_show_suggested_msgs_bar, #btn_show_suggested_msgs').toggle(suggested_msgs_shown);
$('#btn_show_suggested_msgs_bar, #btn_show_suggested_msgs').css('display', (suggested_msgs_shown ? 'block' : 'none'));
thisController.show_popup_near_element($('#popup_text_style'), jqSlot);
}
}
this.get_text_design_params_from_desiger = function (jqInputElement) {
var ret = {};
ret.font = jqInputElement.css('font-family');
ret.font_size = jqInputElement.css('font-size');
ret.color = jqInputElement.css('color');
ret.text_align = jqInputElement.css('text-align');
//debug.log(ret);
//DZ 30sep15: saving old position, and old text: (old = when popup opened). if text was unchanged, we revert the x,y as well
ret.open_state_text = jqInputElement.val();
ret.open_state_left = jqInputElement.parents('.slot_text').css('left');
ret.open_state_top = jqInputElement.parents('.slot_text').css('top');
return ret;
}
this.text_design_popup_revert = function () {
//DZ 13aug14: if font size was changed because of text entry, then dont revert it
if (!desLogic.text_design_popup_revert_data.font_size_unrevertable)
desLogic.text_design_popup_current_target.css({
'font-size': desLogic.text_design_popup_revert_data.font_size,
'line-height': lineHeightMultiplier(parseFloat(desLogic.text_design_popup_revert_data.font_size.replace('px', '')), desLogic.text_design_popup_revert_data.font) + 'px'
});
desLogic.reinit_autosizer(desLogic.text_design_popup_current_target);
desLogic.text_design_popup_current_target.trigger('keyup');
desLogic.text_design_popup_current_target.css({
//DZ 28jul14: adding position fix after font-change (CIE-14 - After max zooming and clicking Cancel text from the bottom part of invitation disappears)
//'font-family': text_design_popup_revert_data.font,
'color': desLogic.text_design_popup_revert_data.color,
'text-align': desLogic.text_design_popup_revert_data.text_align,
});
//DZ 11jan17: REDESIGN
//desLogic.text_design_popup_current_target.parents('.slot_text').css('outline-color', get_outline_color(text_design_popup_revert_data.color));
desLogic.setColorToJQTextSlot(desLogic.text_design_popup_current_target.parents('.slot_text'), desLogic.text_design_popup_revert_data.color);
desLogic.change_text_slot_font(desLogic.text_design_popup_current_target.parents('.slot_text'), desLogic.text_design_popup_revert_data.font);
//thisController.reinit_autosizer(desLogic.text_design_popup_current_target);
//DZ 30sep15: saving old position, and old text: (old = when popup opened). if text was unchanged, we revert the x,y as well
if (desLogic.text_design_popup_current_target.val() == desLogic.text_design_popup_revert_data.open_state_text) {
desLogic.text_design_popup_current_target.parents('.slot_text').css({ left: desLogic.text_design_popup_revert_data.open_state_left, top: desLogic.text_design_popup_revert_data.open_state_top });
}
}
/* -------------------- STICKERS ------------------ */
this.bind_stickers_by_category = function (categoryId) {
//setting active selection in dropdown:
$('#stickers_tooltip .options li').removeClass('active');
$('#stickers_tooltip .options li[value="' + categoryId + '"]').addClass('active');
var categoryName = $('#stickers_tooltip .options li.active').text();
$('#stickers_tooltip .selected p').text(categoryName);
//filling with stickers draggable/clickable:
$('#stickers').empty();
var idx = 0;
var currentContainer;
if (typeof desLogic.all_stickers_by_category[categoryId] == 'undefined') {
debug.error('no such category ' + categoryId + ' in all_stickers_by_category');
}
else {
$(desLogic.all_stickers_by_category[categoryId]).each(function () {
var stickerUrl = '..\\Editor\\images\\Stickers\\index.html' + this.filename;
var stickerThumbSprite = '..\\Editor\\images\\Stickers\\index.html' + this.thumb_filename;
var new_sticker_btn = $('')
.attr({
sticker_url: stickerUrl,
'background-position': '-' + this.thumb_x + ',-' + this.thumb_y
})
.css({
'background-image': 'url(' + stickerThumbSprite + ')',
'background-position': '-' + this.thumb_x + 'px -' + this.thumb_y + 'px'
});
//currentContainer.append(new_sticker_btn);
$('#stickers').append(new_sticker_btn);
idx++;
});
//making sticker buttons draggable to the editor:
$('#stickers .sticker').draggable({
addClasses: false, //this should improve performance (?)
opacity: 0.35,
//helper: "clone",
helper: function () {
return $
(this).clone().appendTo("body").css("zIndex", 50000).show();
},
scroll: false
});
}
}
//YZ 6Oct15: adding public function to retrieve all stickers, for testing purposes
this.get_all_stickers = function () { return desLogic.all_stickers_by_category; }
this.image_design_popup_open = function (jqSlot) {
desLogic.context_slot_photo = jqSlot;
/* 30jul14 eli request : hide frames for first page popup */
/* 21oct14: should be also shown for ecards */
//DZ 20nov17: removed from cards (migrating from 'ecards v2' to 'ecards' (losing old behavior))
if ($('.editorFrame:first:visible').length == 0) // || editorMode == 'ecards')
$('#frames_selection_section').show();
else
$('#frames_selection_section').hide();
//ZOOM:
var curr_matrix = desLogic.context_slot_photo.find('.photo_holder img').panzoom('getMatrix');
var curr_zoom = 1;
if (curr_matrix != null && curr_matrix.length > 0)
curr_zoom = curr_matrix[0];
$("#slider_image_zoom").slider('value', curr_zoom);
//FILTER:
var curr_filter = desLogic.context_slot_photo.attr('filter_name');
if (!curr_filter) curr_filter = 'no-filter';
$('#popup_image_style .filter input[id="' + curr_filter + '"]').prop('checked', true);
//BORDER:
var frame_name = desLogic.context_slot_photo.attr('current_frame');
if (!frame_name) frame_name = 'none';
$('#popup_image_style .frame input[id="' + frame_name + '"]').prop('checked', true);
//REVERT DATA:
desLogic.context_slot_photo_revert_data = { zoom: curr_zoom, rotation: 0, filter: curr_filter, frame: frame_name };
desLogic.context_slot_photo_reverted_image_src = jqSlot.find('.photo_holder img').attr('src');
desLogic.context_slot_photo_reverted_unfiltered_src = desLogic.context_slot_photo.attr('unfiltered_src');
debug.log('opening image_design_popup. revert data=', desLogic.context_slot_photo_revert_data);
thisController.show_popup_near_element($('#popup_image_style'), desLogic.context_slot_photo);
//DZ 28oct14: HOTFIX for getting out of window area:
try {
var jqPopElm = $('#popup_image_style');
if (jqPopElm.is('#popup_image_style')) {
var current_x = parseFloat(jqPopElm.css('left').replace('px', ''));
var leftX = jqPopElm.offset().left;
if (leftX < 0) {
debug.log('fix_popup_pos_near_element FIXING LEFT EDGE X', leftX);
jqPopElm.css('left', current_x + leftX + 'px');
}
else {
//right 'edge'
var rightX = jqPopElm.offset().left + jqPopElm.width();
//var diff = $(window).width() - rightX;
var diff = $('body').width() - rightX;
if (diff < 0) {
debug.log('fix_popup_pos_near_element FIXING RIGHT EDGE X', diff);
jqPopElm.css('left', current_x + diff + 'px');
}
}
}
}
catch (e) {
debug.error('error on edge fixing near_pos', e);
}
};
this.image_design_popup_revert = function () {
debug.log('reverting', desLogic.context_slot_photo_revert_data);
//revert zoom:
var jqElm = desLogic.context_slot_photo.find('.photo_holder img');
jqElm.panzoom('zoom', parseInt(desLogic.context_slot_photo_revert_data.zoom));//, { silent: true });
//revert image:
jqElm.attr('src', desLogic.context_slot_photo_reverted_image_src);
desLogic.context_slot_photo.attr('filter_name', desLogic.context_slot_photo_revert_data.filter);
if (desLogic.context_slot_photo_reverted_unfiltered_src)
desLogic.context_slot_photo.attr('unfiltered_src', desLogic.context_slot_photo_reverted_unfiltered_src);
else
desLogic.context_slot_photo.removeAttr('unfiltered_src');
//BORDER:
//desLogic.context_slot_photo.attr('current_frame', desLogic.context_slot_photo_revert_data.frame);
desLogic.bind_frame_to_slot_photo(desLogic.context_slot_photo, desLogic.context_slot_photo_revert_data.frame);
//putting timeout fixes a very strange issue: (CIE-198 -Photo has been zoomed out and truncated after Cancel after applying photo rotation in designer)
var repeatedHotfix = function () {
desLogic.init_image_size_in_box_container(jqElm);
desLogic.panzoom_init_image(jqElm);
};
//DZ 13jun17: (CIE-198 revisited) after struggling with this issue for awhile, just running this 3 times in a short time
repeatedHotfix();
setTimeout(function () {
repeatedHotfix();
setTimeout(function () {
repeatedHotfix();
}, 250);
}, 50);
};
//open suggsted msgs popup:
//context slot_text should be set before calling this method.
this.show_suggested_msgs_popup = function () {
//step 1: init popup info (if needed)
init_suggested_msgs_if_needed(function () {
thisController.show_popup_centered($('#popup_suggested_msgs'));
});
}
//private method:
function init_suggested_msgs_if_needed(succFunc) {
var jqPopup = $('#popup_suggested_msgs');
if (jqPopup.hasClass('inited')) {
//if already inited
debug.log('sugg msgs already inited');
succFunc();
}
else {
//fill the popup:
debug.log('initing suggested msgs');
now_loading_start();
$.ajax({
method: 'GET', dataType: 'json',
url: suggested_msg_source_url,
error: ajax_show_error_popup_handler, //shows error popup
success: function (resp_json) {
var json_parsed = JSON.parse(resp_json);
debug.log('suggested_msgs resp', json_parsed);
//for each category:
var categories = json_parsed.messages.category;
//categories can be an array, or a single category item (so it has 'message' property)
if (categories.length == 1 || categories.message)
jqPopup.addClass('hide_categories');
$(categories).each(function () {
var thisCategory = this;
var newCatLi = $('
').append($('').attr({ href: '#sugg_cat_' + thisCategory.id }).text(thisCategory.name));
jqPopup.find('.tabs ul').append(newCatLi);
var newMessageDiv = $('').attr({ id: 'sugg_cat_' + thisCategory.id }).append($('
'));
$(thisCategory.message).each(function () {
var thisMessage = this;
newMessageDiv.find('ul').append($('- ').text(fixGIText(thisMessage.txt)));
});
jqPopup.find('.tab-content').append(newMessageDiv);
});
//select first element:
jqPopup.find('.tabs ul li:first').addClass('selected');
jqPopup.find('.tab-content > div:first').css('display', 'block');
jqPopup.addClass('inited');
now_loading_stop();
succFunc();
}
});
}
}
this.bind_simple_popup = function (popup_type, title, bodytext, btntext) {
$('#popup_simple_template').attr('popup_type', popup_type);
//$('#popup_simple_template .title p span.innerTitle').text(title);
$('#popup_simple_template h3').text(title);
$('#popup_simple_template .content p').html(bodytext);
$('#popup_simple_button').text(btntext);
//removing force download attributes (used on download_image)
$('#popup_simple_button').removeAttr('download').removeAttr('href').removeAttr('target');
$('#popup_simple_template img').remove(); //removing any imgs added by download_image_helper (IE support)
$('#popup_simple_template').css('margin-left', -($('#popup_simple_template').width() / 2) + 'px');
//DZ 9aug15: popup_simple_button click action init moved initAll to binding method
//GENERIC POPUP BUTTON:
$('#popup_simple_button').unbind('click');
$('#popup_simple_button').click(function () {
var popupType = $('#popup_simple_template').attr('popup_type');
if (popupType == 'popup_with_close_btn') {
thisController.close_all_popups();
}
else if (popupType == 'download_pdf') {
pdfDoc.save(get_download_filename() + '.pdf');
desLogic.mark_as_clean();
thisController.close_all_popups();
pdfDoc = null;
}
else if (popupType == 'download_image') {
desLogic.mark_as_clean();
thisController.close_all_popups();
return true;
}
});
};
//DZ 11jul17: single point of binding (used to be in 4 different places)
//function open_print_summary_popup() {
// now_loading_start();
// //DZ 21apr15: removed on yair's request
// //$.publish('designer.print', ['print_popup_open']);
// //clearing previous generated preview images (to clear mem)
// $('.print_summary_preview img.generated_preview_page').remove();
// var heightRatio = ($('.editorFrame').height() / $('.editorFrame').width());
// //var canvasW = 300;
// var canvasW = config_render.card_print_summary_width;
// var canvasH = parseInt(canvasW * heightRatio);
// var selectorFirstPages = '.print_summary_preview .grid_1-2:nth-child(1) .page_sheet';
// var selectorSecondPages = '.print_summary_preview .grid_1-2:nth-child(2) .page_sheet';
// render_image_from_frame($('.tabBack .editorFrame'), canvasW, canvasH, function (currentImgData) {
// //$('.print_summary_preview .page_sheet:first').append($('
').attr('id', 'preview_img_back').addClass('generated_preview_page').attr('src', currentImgData))
// $(selectorFirstPages).append($('
').attr('id', 'preview_img_back').addClass('generated_preview_page').attr('src', currentImgData))
// render_image_from_frame($('.tabFront .editorFrame'), canvasW, canvasH, function (currentImgData) {
// //$('.print_summary_preview .page_sheet:first').append($('
').attr('id', 'preview_img_front').addClass('generated_preview_page').attr('src', currentImgData))
// $(selectorFirstPages).append($('
').attr('id', 'preview_img_front').addClass('generated_preview_page').attr('src', currentImgData))
// render_image_from_frame($('.tabInside .editorFrame:first'), canvasW, canvasH, function (currentImgData) {
// //$('.print_summary_preview .page_sheet:last').append($('
').attr('id', 'preview_img_inside1').addClass('generated_preview_page').attr('src', currentImgData));
// $(selectorSecondPages).append($('
').attr('id', 'preview_img_inside1').addClass('generated_preview_page').attr('src', currentImgData));
// render_image_from_frame($('.tabInside .editorFrame:last'), canvasW, canvasH, function (currentImgData) {
// //$('.print_summary_preview .page_sheet:last').append($('
').attr('id', 'preview_img_inside2').addClass('generated_preview_page').attr('src', currentImgData));
// $(selectorSecondPages).append($('
').attr('id', 'preview_img_inside2').addClass('generated_preview_page').attr('src', currentImgData));
// desLogic.func_update_preview_panel();
// //thisController.show_popup_centered($('#popup_print_summary'));
// $('.finish-step').hide();
// $('.finish-step.-first-step').show();
// thisController.show_popup_centered($('#popup_finish_tabs_cards'));
// now_loading_stop();
// });
// });
// });
// });
//};
this.open_incompatible_browser_popup = function () {
uxController.bind_simple_popup("popup_with_close_btn", getLocCaption("pdf_not_supported"), getLocCaption("pdf_not_supported_desc"), getLocCaption("Close"));
uxController.show_popup_centered($('#popup_simple_template'));
};
};
//end of UX controller
;
/*!
* clipboard.js v2.0.0
* https://zenorocha.github.io/clipboard.js
*
* Licensed MIT © Zeno Rocha
*/
!function (t, e) { "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.ClipboardJS = e() : t.ClipboardJS = e() }(this, function () { return function (t) { function e(o) { if (n[o]) return n[o].exports; var r = n[o] = { i: o, l: !1, exports: {} }; return t[o].call(r.exports, r, r.exports, e), r.l = !0, r.exports } var n = {}; return e.m = t, e.c = n, e.i = function (t) { return t }, e.d = function (t, n, o) { e.o(t, n) || Object.defineProperty(t, n, { configurable: !1, enumerable: !0, get: o }) }, e.n = function (t) { var n = t && t.__esModule ? function () { return t.default } : function () { return t }; return e.d(n, "a", n), n }, e.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e) }, e.p = "", e(e.s = 3) }([function (t, e, n) { var o, r, i; !function (a, c) { r = [t, n(7)], o = c, void 0 !== (i = "function" == typeof o ? o.apply(e, r) : o) && (t.exports = i) }(0, function (t, e) { "use strict"; function n(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") } var o = function (t) { return t && t.__esModule ? t : { default: t } }(e), r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t }, i = function () { function t(t, e) { for (var n = 0; n < e.length; n++) { var o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } return function (e, n, o) { return n && t(e.prototype, n), o && t(e, o), e } }(), a = function () { function t(e) { n(this, t), this.resolveOptions(e), this.initSelection() } return i(t, [{ key: "resolveOptions", value: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; this.action = t.action, this.container = t.container, this.emitter = t.emitter, this.target = t.target, this.text = t.text, this.trigger = t.trigger, this.selectedText = "" } }, { key: "initSelection", value: function () { this.text ? this.selectFake() : this.target && this.selectTarget() } }, { key: "selectFake", value: function () { var t = this, e = "rtl" == document.documentElement.getAttribute("dir"); this.removeFake(), this.fakeHandlerCallback = function () { return t.removeFake() }, this.fakeHandler = this.container.addEventListener("click", this.fakeHandlerCallback) || !0, this.fakeElem = document.createElement("textarea"), this.fakeElem.style.fontSize = "12pt", this.fakeElem.style.border = "0", this.fakeElem.style.padding = "0", this.fakeElem.style.margin = "0", this.fakeElem.style.position = "absolute", this.fakeElem.style[e ? "right" : "left"] = "-9999px"; var n = window.pageYOffset || document.documentElement.scrollTop; this.fakeElem.style.top = n + "px", this.fakeElem.setAttribute("readonly", ""), this.fakeElem.value = this.text, this.container.appendChild(this.fakeElem), this.selectedText = (0, o.default)(this.fakeElem), this.copyText() } }, { key: "removeFake", value: function () { this.fakeHandler && (this.container.removeEventListener("click", this.fakeHandlerCallback), this.fakeHandler = null, this.fakeHandlerCallback = null), this.fakeElem && (this.container.removeChild(this.fakeElem), this.fakeElem = null) } }, { key: "selectTarget", value: function () { this.selectedText = (0, o.default)(this.target), this.copyText() } }, { key: "copyText", value: function () { var t = void 0; try { t = document.execCommand(this.action) } catch (e) { t = !1 } this.handleResult(t) } }, { key: "handleResult", value: function (t) { this.emitter.emit(t ? "success" : "error", { action: this.action, text: this.selectedText, trigger: this.trigger, clearSelection: this.clearSelection.bind(this) }) } }, { key: "clearSelection", value: function () { this.trigger && this.trigger.focus(), window.getSelection().removeAllRanges() } }, { key: "destroy", value: function () { this.removeFake() } }, { key: "action", set: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "copy"; if (this._action = t, "copy" !== this._action && "cut" !== this._action) throw new Error('Invalid "action" value, use either "copy" or "cut"') }, get: function () { return this._action } }, { key: "target", set: function (t) { if (void 0 !== t) { if (!t || "object" !== (void 0 === t ? "undefined" : r(t)) || 1 !== t.nodeType) throw new Error('Invalid "target" value, use a valid Element'); if ("copy" === this.action && t.hasAttribute("disabled")) throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); if ("cut" === this.action && (t.hasAttribute("readonly") || t.hasAttribute("disabled"))) throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); this._target = t } }, get: function () { return this._target } }]), t }(); t.exports = a }) }, function (t, e, n) { function o(t, e, n) { if (!t && !e && !n) throw new Error("Missing required arguments"); if (!c.string(e)) throw new TypeError("Second argument must be a String"); if (!c.fn(n)) throw new TypeError("Third argument must be a Function"); if (c.node(t)) return r(t, e, n); if (c.nodeList(t)) return i(t, e, n); if (c.string(t)) return a(t, e, n); throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList") } function r(t, e, n) { return t.addEventListener(e, n), { destroy: function () { t.removeEventListener(e, n) } } } function i(t, e, n) { return Array.prototype.forEach.call(t, function (t) { t.addEventListener(e, n) }), { destroy: function () { Array.prototype.forEach.call(t, function (t) { t.removeEventListener(e, n) }) } } } function a(t, e, n) { return u(document.body, t, e, n) } var c = n(6), u = n(5); t.exports = o }, function (t, e) { function n() { } n.prototype = { on: function (t, e, n) { var o = this.e || (this.e = {}); return (o[t] || (o[t] = [])).push({ fn: e, ctx: n }), this }, once: function (t, e, n) { function o() { r.off(t, o), e.apply(n, arguments) } var r = this; return o._ = e, this.on(t, o, n) }, emit: function (t) { var e = [].slice.call(arguments, 1), n = ((this.e || (this.e = {}))[t] || []).slice(), o = 0, r = n.length; for (o; o < r; o++)n[o].fn.apply(n[o].ctx, e); return this }, off: function (t, e) { var n = this.e || (this.e = {}), o = n[t], r = []; if (o && e) for (var i = 0, a = o.length; i < a; i++)o[i].fn !== e && o[i].fn._ !== e && r.push(o[i]); return r.length ? n[t] = r : delete n[t], this } }, t.exports = n }, function (t, e, n) { var o, r, i; !function (a, c) { r = [t, n(0), n(2), n(1)], o = c, void 0 !== (i = "function" == typeof o ? o.apply(e, r) : o) && (t.exports = i) }(0, function (t, e, n, o) { "use strict"; function r(t) { return t && t.__esModule ? t : { default: t } } function i(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") } function a(t, e) { if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return !e || "object" != typeof e && "function" != typeof e ? t : e } function c(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function, not " + typeof e); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, enumerable: !1, writable: !0, configurable: !0 } }), e && (Object.setPrototypeOf ? Object.setPrototypeOf(t, e) : t.__proto__ = e) } function u(t, e) { var n = "data-clipboard-" + t; if (e.hasAttribute(n)) return e.getAttribute(n) } var l = r(e), s = r(n), f = r(o), d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t }, h = function () { function t(t, e) { for (var n = 0; n < e.length; n++) { var o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } return function (e, n, o) { return n && t(e.prototype, n), o && t(e, o), e } }(), p = function (t) { function e(t, n) { i(this, e); var o = a(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this)); return o.resolveOptions(n), o.listenClick(t), o } return c(e, t), h(e, [{ key: "resolveOptions", value: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; this.action = "function" == typeof t.action ? t.action : this.defaultAction, this.target = "function" == typeof t.target ? t.target : this.defaultTarget, this.text = "function" == typeof t.text ? t.text : this.defaultText, this.container = "object" === d(t.container) ? t.container : document.body } }, { key: "listenClick", value: function (t) { var e = this; this.listener = (0, f.default)(t, "click", function (t) { return e.onClick(t) }) } }, { key: "onClick", value: function (t) { var e = t.delegateTarget || t.currentTarget; this.clipboardAction && (this.clipboardAction = null), this.clipboardAction = new l.default({ action: this.action(e), target: this.target(e), text: this.text(e), container: this.container, trigger: e, emitter: this }) } }, { key: "defaultAction", value: function (t) { return u("action", t) } }, { key: "defaultTarget", value: function (t) { var e = u("target", t); if (e) return document.querySelector(e) } }, { key: "defaultText", value: function (t) { return u("text", t) } }, { key: "destroy", value: function () { this.listener.destroy(), this.clipboardAction && (this.clipboardAction.destroy(), this.clipboardAction = null) } }], [{ key: "isSupported", value: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : ["copy", "cut"], e = "string" == typeof t ? [t] : t, n = !!document.queryCommandSupported; return e.forEach(function (t) { n = n && !!document.queryCommandSupported(t) }), n } }]), e }(s.default); t.exports = p }) }, function (t, e) { function n(t, e) { for (; t && t.nodeType !== o;) { if ("function" == typeof t.matches && t.matches(e)) return t; t = t.parentNode } } var o = 9; if ("undefined" != typeof Element && !Element.prototype.matches) { var r = Element.prototype; r.matches = r.matchesSelector || r.mozMatchesSelector || r.msMatchesSelector || r.oMatchesSelector || r.webkitMatchesSelector } t.exports = n }, function (t, e, n) { function o(t, e, n, o, r) { var a = i.apply(this, arguments); return t.addEventListener(n, a, r), { destroy: function () { t.removeEventListener(n, a, r) } } } function r(t, e, n, r, i) { return "function" == typeof t.addEventListener ? o.apply(null, arguments) : "function" == typeof n ? o.bind(null, document).apply(null, arguments) : ("string" == typeof t && (t = document.querySelectorAll(t)), Array.prototype.map.call(t, function (t) { return o(t, e, n, r, i) })) } function i(t, e, n, o) { return function (n) { n.delegateTarget = a(n.target, e), n.delegateTarget && o.call(t, n) } } var a = n(4); t.exports = r }, function (t, e) { e.node = function (t) { return void 0 !== t && t instanceof HTMLElement && 1 === t.nodeType }, e.nodeList = function (t) { var n = Object.prototype.toString.call(t); return void 0 !== t && ("[object NodeList]" === n || "[object HTMLCollection]" === n) && "length" in t && (0 === t.length || e.node(t[0])) }, e.string = function (t) { return "string" == typeof t || t instanceof String }, e.fn = function (t) { return "[object Function]" === Object.prototype.toString.call(t) } }, function (t, e) { function n(t) { var e; if ("SELECT" === t.nodeName) t.focus(), e = t.value; else if ("INPUT" === t.nodeName || "TEXTAREA" === t.nodeName) { var n = t.hasAttribute("readonly"); n || t.setAttribute("readonly", ""), t.select(), t.setSelectionRange(0, t.value.length), n || t.removeAttribute("readonly"), e = t.value } else { t.hasAttribute("contenteditable") && t.focus(); var o = window.getSelection(), r = document.createRange(); r.selectNodeContents(t), o.removeAllRanges(), o.addRange(r), e = o.toString() } return e } t.exports = n }]) });;
/* qtip2 v3.0.3 | Plugins: tips modal viewport svg imagemap ie6 | Styles: core basic css3 | qtip2.com | Licensed MIT | Wed May 11 2016 22:31:31 */
!function(a,b,c){!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.qtip&&a(jQuery)}(function(d){"use strict";function e(a,b,c,e){this.id=c,this.target=a,this.tooltip=F,this.elements={target:a},this._id=S+"-"+c,this.timers={img:{}},this.options=b,this.plugins={},this.cache={event:{},target:d(),disabled:E,attr:e,onTooltip:E,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=E}function f(a){return a===F||"object"!==d.type(a)}function g(a){return!(d.isFunction(a)||a&&a.attr||a.length||"object"===d.type(a)&&(a.jquery||a.then))}function h(a){var b,c,e,h;return f(a)?E:(f(a.metadata)&&(a.metadata={type:a.metadata}),"content"in a&&(b=a.content,f(b)||b.jquery||b.done?(c=g(b)?E:b,b=a.content={text:c}):c=b.text,"ajax"in b&&(e=b.ajax,h=e&&e.once!==E,delete b.ajax,b.text=function(a,b){var f=c||d(this).attr(b.options.content.attr)||"Loading...",g=d.ajax(d.extend({},e,{context:b})).then(e.success,F,e.error).then(function(a){return a&&h&&b.set("content.text",a),a},function(a,c,d){b.destroyed||0===a.status||b.set("content.text",c+": "+d)});return h?f:(b.set("content.text",f),g)}),"title"in b&&(d.isPlainObject(b.title)&&(b.button=b.title.button,b.title=b.title.text),g(b.title||E)&&(b.title=E))),"position"in a&&f(a.position)&&(a.position={my:a.position,at:a.position}),"show"in a&&f(a.show)&&(a.show=a.show.jquery?{target:a.show}:a.show===D?{ready:D}:{event:a.show}),"hide"in a&&f(a.hide)&&(a.hide=a.hide.jquery?{target:a.hide}:{event:a.hide}),"style"in a&&f(a.style)&&(a.style={classes:a.style}),d.each(R,function(){this.sanitize&&this.sanitize(a)}),a)}function i(a,b){for(var c,d=0,e=a,f=b.split(".");e=e[f[d++]];)d0?setTimeout(d.proxy(a,this),b):void a.call(this)}function m(a){this.tooltip.hasClass(aa)||(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=l.call(this,function(){this.toggle(D,a)},this.options.show.delay))}function n(a){if(!this.tooltip.hasClass(aa)&&!this.destroyed){var b=d(a.relatedTarget),c=b.closest(W)[0]===this.tooltip[0],e=b[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==b[0]&&"mouse"===this.options.position.target&&c||this.options.hide.fixed&&/mouse(out|leave|move)/.test(a.type)&&(c||e))try{a.preventDefault(),a.stopImmediatePropagation()}catch(f){}else this.timers.hide=l.call(this,function(){this.toggle(E,a)},this.options.hide.delay,this)}}function o(a){!this.tooltip.hasClass(aa)&&this.options.hide.inactive&&(clearTimeout(this.timers.inactive),this.timers.inactive=l.call(this,function(){this.hide(a)},this.options.hide.inactive))}function p(a){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(a)}function q(a,c,e){d(b.body).delegate(a,(c.split?c:c.join("."+S+" "))+"."+S,function(){var a=y.api[d.attr(this,U)];a&&!a.disabled&&e.apply(a,arguments)})}function r(a,c,f){var g,i,j,k,l,m=d(b.body),n=a[0]===b?m:a,o=a.metadata?a.metadata(f.metadata):F,p="html5"===f.metadata.type&&o?o[f.metadata.name]:F,q=a.data(f.metadata.name||"qtipopts");try{q="string"==typeof q?d.parseJSON(q):q}catch(r){}if(k=d.extend(D,{},y.defaults,f,"object"==typeof q?h(q):F,h(p||o)),i=k.position,k.id=c,"boolean"==typeof k.content.text){if(j=a.attr(k.content.attr),k.content.attr===E||!j)return E;k.content.text=j}if(i.container.length||(i.container=m),i.target===E&&(i.target=n),k.show.target===E&&(k.show.target=n),k.show.solo===D&&(k.show.solo=i.container.closest("body")),k.hide.target===E&&(k.hide.target=n),k.position.viewport===D&&(k.position.viewport=i.container),i.container=i.container.eq(0),i.at=new A(i.at,D),i.my=new A(i.my),a.data(S))if(k.overwrite)a.qtip("destroy",!0);else if(k.overwrite===E)return E;return a.attr(T,c),k.suppress&&(l=a.attr("title"))&&a.removeAttr("title").attr(ca,l).attr("title",""),g=new e(a,k,c,!!j),a.data(S,g),g}function s(a){return a.charAt(0).toUpperCase()+a.slice(1)}function t(a,b){var d,e,f=b.charAt(0).toUpperCase()+b.slice(1),g=(b+" "+va.join(f+" ")+f).split(" "),h=0;if(ua[b])return a.css(ua[b]);for(;d=g[h++];)if((e=a.css(d))!==c)return ua[b]=d,e}function u(a,b){return Math.ceil(parseFloat(t(a,b)))}function v(a,b){this._ns="tip",this.options=b,this.offset=b.offset,this.size=[b.width,b.height],this.qtip=a,this.init(a)}function w(a,b){this.options=b,this._ns="-modal",this.qtip=a,this.init(a)}function x(a){this._ns="ie6",this.qtip=a,this.init(a)}var y,z,A,B,C,D=!0,E=!1,F=null,G="x",H="y",I="width",J="height",K="top",L="left",M="bottom",N="right",O="center",P="flipinvert",Q="shift",R={},S="qtip",T="data-hasqtip",U="data-qtip-id",V=["ui-widget","ui-tooltip"],W="."+S,X="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),Y=S+"-fixed",Z=S+"-default",$=S+"-focus",_=S+"-hover",aa=S+"-disabled",ba="_replacedByqTip",ca="oldtitle",da={ie:function(){var a,c;for(a=4,c=b.createElement("div");(c.innerHTML="")&&c.getElementsByTagName("i")[0];a+=1);return a>4?a:NaN}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||E};z=e.prototype,z._when=function(a){return d.when.apply(d,a)},z.render=function(a){if(this.rendered||this.destroyed)return this;var b=this,c=this.options,e=this.cache,f=this.elements,g=c.content.text,h=c.content.title,i=c.content.button,j=c.position,k=[];return d.attr(this.target[0],"aria-describedby",this._id),e.posClass=this._createPosClass((this.position={my:j.my,at:j.at}).my),this.tooltip=f.tooltip=d("",{id:this._id,"class":[S,Z,c.style.classes,e.posClass].join(" "),width:c.style.width||"",height:c.style.height||"",tracking:"mouse"===j.target&&j.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":E,"aria-describedby":this._id+"-content","aria-hidden":D}).toggleClass(aa,this.disabled).attr(U,this.id).data(S,this).appendTo(j.container).append(f.content=d("",{"class":S+"-content",id:this._id+"-content","aria-atomic":D})),this.rendered=-1,this.positioning=D,h&&(this._createTitle(),d.isFunction(h)||k.push(this._updateTitle(h,E))),i&&this._createButton(),d.isFunction(g)||k.push(this._updateContent(g,E)),this.rendered=D,this._setWidget(),d.each(R,function(a){var c;"render"===this.initialize&&(c=this(b))&&(b.plugins[a]=c)}),this._unassignEvents(),this._assignEvents(),this._when(k).then(function(){b._trigger("render"),b.positioning=E,b.hiddenDuringWait||!c.show.ready&&!a||b.toggle(D,e.event,E),b.hiddenDuringWait=E}),y.api[this.id]=this,this},z.destroy=function(a){function b(){if(!this.destroyed){this.destroyed=D;var a,b=this.target,c=b.attr(ca);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),d.each(this.plugins,function(){this.destroy&&this.destroy()});for(a in this.timers)this.timers.hasOwnProperty(a)&&clearTimeout(this.timers[a]);b.removeData(S).removeAttr(U).removeAttr(T).removeAttr("aria-describedby"),this.options.suppress&&c&&b.attr("title",c).removeAttr(ca),this._unassignEvents(),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=F,delete y.api[this.id]}}return this.destroyed?this.target:(a===D&&"hide"!==this.triggering||!this.rendered?b.call(this):(this.tooltip.one("tooltiphidden",d.proxy(b,this)),!this.triggering&&this.hide()),this.target)},B=z.checks={builtin:{"^id$":function(a,b,c,e){var f=c===D?y.nextid:c,g=S+"-"+f;f!==E&&f.length>0&&!d("#"+g).length?(this._id=g,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):a[b]=e},"^prerender":function(a,b,c){c&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(a,b,c){this._updateContent(c)},"^content.attr$":function(a,b,c,d){this.options.content.text===this.target.attr(d)&&this._updateContent(this.target.attr(c))},"^content.title$":function(a,b,c){return c?(c&&!this.elements.title&&this._createTitle(),void this._updateTitle(c)):this._removeTitle()},"^content.button$":function(a,b,c){this._updateButton(c)},"^content.title.(text|button)$":function(a,b,c){this.set("content."+b,c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(this.position[b]=a[b]=new A(c,"at"===b))},"^position.container$":function(a,b,c){this.rendered&&this.tooltip.appendTo(c)},"^show.ready$":function(a,b,c){c&&(!this.rendered&&this.render(D)||this.toggle(D))},"^style.classes$":function(a,b,c,d){this.rendered&&this.tooltip.removeClass(d).addClass(c)},"^style.(width|height)":function(a,b,c){this.rendered&&this.tooltip.css(b,c)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(a,b,c){this.rendered&&this.tooltip.toggleClass(Z,!!c)},"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){this.rendered&&this.tooltip[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var a=this.options.position;this.tooltip.attr("tracking","mouse"===a.target&&a.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},z.get=function(a){if(this.destroyed)return this;var b=i(this.options,a.toLowerCase()),c=b[0][b[1]];return c.precedance?c.string():c};var ea=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,fa=/^prerender|show\.ready/i;z.set=function(a,b){if(this.destroyed)return this;var c,e=this.rendered,f=E,g=this.options;return"string"==typeof a?(c=a,a={},a[c]=b):a=d.extend({},a),d.each(a,function(b,c){if(e&&fa.test(b))return void delete a[b];var h,j=i(g,b.toLowerCase());h=j[0][j[1]],j[0][j[1]]=c&&c.nodeType?d(c):c,f=ea.test(b)||f,a[b]=[j[0],j[1],c,h]}),h(g),this.positioning=D,d.each(a,d.proxy(j,this)),this.positioning=E,this.rendered&&this.tooltip[0].offsetWidth>0&&f&&this.reposition("mouse"===g.position.target?F:this.cache.event),this},z._update=function(a,b){var c=this,e=this.cache;return this.rendered&&a?(d.isFunction(a)&&(a=a.call(this.elements.target,e.event,this)||""),d.isFunction(a.then)?(e.waiting=D,a.then(function(a){return e.waiting=E,c._update(a,b)},F,function(a){return c._update(a,b)})):a===E||!a&&""!==a?E:(a.jquery&&a.length>0?b.empty().append(a.css({display:"block",visibility:"visible"})):b.html(a),this._waitForContent(b).then(function(a){c.rendered&&c.tooltip[0].offsetWidth>0&&c.reposition(e.event,!a.length)}))):E},z._waitForContent=function(a){var b=this.cache;return b.waiting=D,(d.fn.imagesLoaded?a.imagesLoaded():(new d.Deferred).resolve([])).done(function(){b.waiting=E}).promise()},z._updateContent=function(a,b){this._update(a,this.elements.content,b)},z._updateTitle=function(a,b){this._update(a,this.elements.title,b)===E&&this._removeTitle(E)},z._createTitle=function(){var a=this.elements,b=this._id+"-title";a.titlebar&&this._removeTitle(),a.titlebar=d("",{"class":S+"-titlebar "+(this.options.style.widget?k("header"):"")}).append(a.title=d("",{id:b,"class":S+"-title","aria-atomic":D})).insertBefore(a.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus","down"===a.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover","mouseover"===a.type)}),this.options.content.button&&this._createButton()},z._removeTitle=function(a){var b=this.elements;b.title&&(b.titlebar.remove(),b.titlebar=b.title=b.button=F,a!==E&&this.reposition())},z._createPosClass=function(a){return S+"-pos-"+(a||this.options.position.my).abbrev()},z.reposition=function(c,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=D;var f,g,h,i,j=this.cache,k=this.tooltip,l=this.options.position,m=l.target,n=l.my,o=l.at,p=l.viewport,q=l.container,r=l.adjust,s=r.method.split(" "),t=k.outerWidth(E),u=k.outerHeight(E),v=0,w=0,x=k.css("position"),y={left:0,top:0},z=k[0].offsetWidth>0,A=c&&"scroll"===c.type,B=d(a),C=q[0].ownerDocument,F=this.mouse;if(d.isArray(m)&&2===m.length)o={x:L,y:K},y={left:m[0],top:m[1]};else if("mouse"===m)o={x:L,y:K},(!r.mouse||this.options.hide.distance)&&j.origin&&j.origin.pageX?c=j.origin:!c||c&&("resize"===c.type||"scroll"===c.type)?c=j.event:F&&F.pageX&&(c=F),"static"!==x&&(y=q.offset()),C.body.offsetWidth!==(a.innerWidth||C.documentElement.clientWidth)&&(g=d(b.body).offset()),y={left:c.pageX-y.left+(g&&g.left||0),top:c.pageY-y.top+(g&&g.top||0)},r.mouse&&A&&F&&(y.left-=(F.scrollX||0)-B.scrollLeft(),y.top-=(F.scrollY||0)-B.scrollTop());else{if("event"===m?c&&c.target&&"scroll"!==c.type&&"resize"!==c.type?j.target=d(c.target):c.target||(j.target=this.elements.target):"event"!==m&&(j.target=d(m.jquery?m:this.elements.target)),m=j.target,m=d(m).eq(0),0===m.length)return this;m[0]===b||m[0]===a?(v=da.iOS?a.innerWidth:m.width(),w=da.iOS?a.innerHeight:m.height(),m[0]===a&&(y={top:(p||m).scrollTop(),left:(p||m).scrollLeft()})):R.imagemap&&m.is("area")?f=R.imagemap(this,m,o,R.viewport?s:E):R.svg&&m&&m[0].ownerSVGElement?f=R.svg(this,m,o,R.viewport?s:E):(v=m.outerWidth(E),w=m.outerHeight(E),y=m.offset()),f&&(v=f.width,w=f.height,g=f.offset,y=f.position),y=this.reposition.offset(m,y,q),(da.iOS>3.1&&da.iOS<4.1||da.iOS>=4.3&&da.iOS<4.33||!da.iOS&&"fixed"===x)&&(y.left-=B.scrollLeft(),y.top-=B.scrollTop()),(!f||f&&f.adjustable!==E)&&(y.left+=o.x===N?v:o.x===O?v/2:0,y.top+=o.y===M?w:o.y===O?w/2:0)}return y.left+=r.x+(n.x===N?-t:n.x===O?-t/2:0),y.top+=r.y+(n.y===M?-u:n.y===O?-u/2:0),R.viewport?(h=y.adjusted=R.viewport(this,y,l,v,w,t,u),g&&h.left&&(y.left+=g.left),g&&h.top&&(y.top+=g.top),h.my&&(this.position.my=h.my)):y.adjusted={left:0,top:0},j.posClass!==(i=this._createPosClass(this.position.my))&&(j.posClass=i,k.removeClass(j.posClass).addClass(i)),this._trigger("move",[y,p.elem||p],c)?(delete y.adjusted,e===E||!z||isNaN(y.left)||isNaN(y.top)||"mouse"===m||!d.isFunction(l.effect)?k.css(y):d.isFunction(l.effect)&&(l.effect.call(k,this,d.extend({},y)),k.queue(function(a){d(this).css({opacity:"",height:""}),da.ie&&this.style.removeAttribute("filter"),a()})),this.positioning=E,this):this},z.reposition.offset=function(a,c,e){function f(a,b){c.left+=b*a.scrollLeft(),c.top+=b*a.scrollTop()}if(!e[0])return c;var g,h,i,j,k=d(a[0].ownerDocument),l=!!da.ie&&"CSS1Compat"!==b.compatMode,m=e[0];do"static"!==(h=d.css(m,"position"))&&("fixed"===h?(i=m.getBoundingClientRect(),f(k,-1)):(i=d(m).position(),i.left+=parseFloat(d.css(m,"borderLeftWidth"))||0,i.top+=parseFloat(d.css(m,"borderTopWidth"))||0),c.left-=i.left+(parseFloat(d.css(m,"marginLeft"))||0),c.top-=i.top+(parseFloat(d.css(m,"marginTop"))||0),g||"hidden"===(j=d.css(m,"overflow"))||"visible"===j||(g=d(m)));while(m=m.offsetParent);return g&&(g[0]!==k[0]||l)&&f(g,1),c};var ga=(A=z.reposition.Corner=function(a,b){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,O).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!b;var c=a.charAt(0);this.precedance="t"===c||"b"===c?H:G}).prototype;ga.invert=function(a,b){this[a]=this[a]===L?N:this[a]===N?L:b||this[a]},ga.string=function(a){var b=this.x,c=this.y,d=b!==c?"center"===b||"center"!==c&&(this.precedance===H||this.forceY)?[c,b]:[b,c]:[b];return a!==!1?d.join(" "):d},ga.abbrev=function(){var a=this.string(!1);return a[0].charAt(0)+(a[1]&&a[1].charAt(0)||"")},ga.clone=function(){return new A(this.string(),this.forceY)},z.toggle=function(a,c){var e=this.cache,f=this.options,g=this.tooltip;if(c){if(/over|enter/.test(c.type)&&e.event&&/out|leave/.test(e.event.type)&&f.show.target.add(c.target).length===f.show.target.length&&g.has(c.relatedTarget).length)return this;e.event=d.event.fix(c)}if(this.waiting&&!a&&(this.hiddenDuringWait=D),!this.rendered)return a?this.render(1):this;if(this.destroyed||this.disabled)return this;var h,i,j,k=a?"show":"hide",l=this.options[k],m=this.options.position,n=this.options.content,o=this.tooltip.css("width"),p=this.tooltip.is(":visible"),q=a||1===l.target.length,r=!c||l.target.length<2||e.target[0]===c.target;return(typeof a).search("boolean|number")&&(a=!p),h=!g.is(":animated")&&p===a&&r,i=h?F:!!this._trigger(k,[90]),this.destroyed?this:(i!==E&&a&&this.focus(c),!i||h?this:(d.attr(g[0],"aria-hidden",!a),a?(this.mouse&&(e.origin=d.event.fix(this.mouse)),d.isFunction(n.text)&&this._updateContent(n.text,E),d.isFunction(n.title)&&this._updateTitle(n.title,E),!C&&"mouse"===m.target&&m.adjust.mouse&&(d(b).bind("mousemove."+S,this._storeMouse),C=D),o||g.css("width",g.outerWidth(E)),this.reposition(c,arguments[2]),o||g.css("width",""),l.solo&&("string"==typeof l.solo?d(l.solo):d(W,l.solo)).not(g).not(l.target).qtip("hide",new d.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete e.origin,C&&!d(W+'[tracking="true"]:visible',l.solo).not(g).length&&(d(b).unbind("mousemove."+S),C=E),this.blur(c)),j=d.proxy(function(){a?(da.ie&&g[0].style.removeAttribute("filter"),g.css("overflow",""),"string"==typeof l.autofocus&&d(this.options.show.autofocus,g).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):g.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(a?"visible":"hidden")},this),l.effect===E||q===E?(g[k](),j()):d.isFunction(l.effect)?(g.stop(1,1),l.effect.call(g,this),g.queue("fx",function(a){j(),a()})):g.fadeTo(90,a?1:0,j),a&&l.target.trigger("qtip-"+this.id+"-inactive"),this))},z.show=function(a){return this.toggle(D,a)},z.hide=function(a){return this.toggle(E,a)},z.focus=function(a){if(!this.rendered||this.destroyed)return this;var b=d(W),c=this.tooltip,e=parseInt(c[0].style.zIndex,10),f=y.zindex+b.length;return c.hasClass($)||this._trigger("focus",[f],a)&&(e!==f&&(b.each(function(){this.style.zIndex>e&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+$).qtip("blur",a)),c.addClass($)[0].style.zIndex=f),this},z.blur=function(a){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass($),this._trigger("blur",[this.tooltip.css("zIndex")],a),this)},z.disable=function(a){return this.destroyed?this:("toggle"===a?a=!(this.rendered?this.tooltip.hasClass(aa):this.disabled):"boolean"!=typeof a&&(a=D),this.rendered&&this.tooltip.toggleClass(aa,a).attr("aria-disabled",a),this.disabled=!!a,this)},z.enable=function(){return this.disable(E)},z._createButton=function(){var a=this,b=this.elements,c=b.tooltip,e=this.options.content.button,f="string"==typeof e,g=f?e:"Close tooltip";b.button&&b.button.remove(),e.jquery?b.button=e:b.button=d("",{"class":"qtip-close "+(this.options.style.widget?"":S+"-icon"),title:g,"aria-label":g}).prepend(d("",{"class":"ui-icon ui-icon-close",html:"×"})),b.button.appendTo(b.titlebar||c).attr("role","button").click(function(b){return c.hasClass(aa)||a.hide(b),E})},z._updateButton=function(a){if(!this.rendered)return E;var b=this.elements.button;a?this._createButton():b.remove()},z._setWidget=function(){var a=this.options.style.widget,b=this.elements,c=b.tooltip,d=c.hasClass(aa);c.removeClass(aa),aa=a?"ui-state-disabled":"qtip-disabled",c.toggleClass(aa,d),c.toggleClass("ui-helper-reset "+k(),a).toggleClass(Z,this.options.style.def&&!a),b.content&&b.content.toggleClass(k("content"),a),b.titlebar&&b.titlebar.toggleClass(k("header"),a),b.button&&b.button.toggleClass(S+"-icon",!a)},z._storeMouse=function(a){return(this.mouse=d.event.fix(a)).type="mousemove",this},z._bind=function(a,b,c,e,f){if(a&&c&&b.length){var g="."+this._id+(e?"-"+e:"");return d(a).bind((b.split?b:b.join(g+" "))+g,d.proxy(c,f||this)),this}},z._unbind=function(a,b){return a&&d(a).unbind("."+this._id+(b?"-"+b:"")),this},z._trigger=function(a,b,c){var e=new d.Event("tooltip"+a);return e.originalEvent=c&&d.extend({},c)||this.cache.event||F,this.triggering=a,this.tooltip.trigger(e,[this].concat(b||[])),this.triggering=E,!e.isDefaultPrevented()},z._bindEvents=function(a,b,c,e,f,g){var h=c.filter(e).add(e.filter(c)),i=[];h.length&&(d.each(b,function(b,c){var e=d.inArray(c,a);e>-1&&i.push(a.splice(e,1)[0])}),i.length&&(this._bind(h,i,function(a){var b=this.rendered?this.tooltip[0].offsetWidth>0:!1;(b?g:f).call(this,a)}),c=c.not(h),e=e.not(h))),this._bind(c,a,f),this._bind(e,b,g)},z._assignInitialEvents=function(a){function b(a){return this.disabled||this.destroyed?E:(this.cache.event=a&&d.event.fix(a),this.cache.target=a&&d(a.target),clearTimeout(this.timers.show),void(this.timers.show=l.call(this,function(){this.render("object"==typeof a||c.show.ready)},c.prerender?0:c.show.delay)))}var c=this.options,e=c.show.target,f=c.hide.target,g=c.show.event?d.trim(""+c.show.event).split(" "):[],h=c.hide.event?d.trim(""+c.hide.event).split(" "):[];this._bind(this.elements.target,["remove","removeqtip"],function(){this.destroy(!0)},"destroy"),/mouse(over|enter)/i.test(c.show.event)&&!/mouse(out|leave)/i.test(c.hide.event)&&h.push("mouseleave"),this._bind(e,"mousemove",function(a){this._storeMouse(a),this.cache.onTarget=D}),this._bindEvents(g,h,e,f,b,function(){return this.timers?void clearTimeout(this.timers.show):E}),(c.show.ready||c.prerender)&&b.call(this,a)},z._assignEvents=function(){var c=this,e=this.options,f=e.position,g=this.tooltip,h=e.show.target,i=e.hide.target,j=f.container,k=f.viewport,l=d(b),q=d(a),r=e.show.event?d.trim(""+e.show.event).split(" "):[],s=e.hide.event?d.trim(""+e.hide.event).split(" "):[];d.each(e.events,function(a,b){c._bind(g,"toggle"===a?["tooltipshow","tooltiphide"]:["tooltip"+a],b,null,g)}),/mouse(out|leave)/i.test(e.hide.event)&&"window"===e.hide.leave&&this._bind(l,["mouseout","blur"],function(a){/select|option/.test(a.target.nodeName)||a.relatedTarget||this.hide(a)}),e.hide.fixed?i=i.add(g.addClass(Y)):/mouse(over|enter)/i.test(e.show.event)&&this._bind(i,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+e.hide.event).indexOf("unfocus")>-1&&this._bind(j.closest("html"),["mousedown","touchstart"],function(a){var b=d(a.target),c=this.rendered&&!this.tooltip.hasClass(aa)&&this.tooltip[0].offsetWidth>0,e=b.parents(W).filter(this.tooltip[0]).length>0;b[0]===this.target[0]||b[0]===this.tooltip[0]||e||this.target.has(b[0]).length||!c||this.hide(a)}),"number"==typeof e.hide.inactive&&(this._bind(h,"qtip-"+this.id+"-inactive",o,"inactive"),this._bind(i.add(g),y.inactiveEvents,o)),this._bindEvents(r,s,h,i,m,n),this._bind(h.add(g),"mousemove",function(a){if("number"==typeof e.hide.distance){var b=this.cache.origin||{},c=this.options.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&this.hide(a)}this._storeMouse(a)}),"mouse"===f.target&&f.adjust.mouse&&(e.hide.event&&this._bind(h,["mouseenter","mouseleave"],function(a){return this.cache?void(this.cache.onTarget="mouseenter"===a.type):E}),this._bind(l,"mousemove",function(a){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(aa)&&this.tooltip[0].offsetWidth>0&&this.reposition(a)})),(f.adjust.resize||k.length)&&this._bind(d.event.special.resize?k:q,"resize",p),f.adjust.scroll&&this._bind(q.add(f.container),"scroll",p)},z._unassignEvents=function(){var c=this.options,e=c.show.target,f=c.hide.target,g=d.grep([this.elements.target[0],this.rendered&&this.tooltip[0],c.position.container[0],c.position.viewport[0],c.position.container.closest("html")[0],a,b],function(a){return"object"==typeof a});e&&e.toArray&&(g=g.concat(e.toArray())),f&&f.toArray&&(g=g.concat(f.toArray())),this._unbind(g)._unbind(g,"destroy")._unbind(g,"inactive")},d(function(){q(W,["mouseenter","mouseleave"],function(a){var b="mouseenter"===a.type,c=d(a.currentTarget),e=d(a.relatedTarget||a.target),f=this.options;b?(this.focus(a),c.hasClass(Y)&&!c.hasClass(aa)&&clearTimeout(this.timers.hide)):"mouse"===f.position.target&&f.position.adjust.mouse&&f.hide.event&&f.show.target&&!e.closest(f.show.target[0]).length&&this.hide(a),c.toggleClass(_,b)}),q("["+U+"]",X,o)}),y=d.fn.qtip=function(a,b,e){var f=(""+a).toLowerCase(),g=F,i=d.makeArray(arguments).slice(1),j=i[i.length-1],k=this[0]?d.data(this[0],S):F;return!arguments.length&&k||"api"===f?k:"string"==typeof a?(this.each(function(){var a=d.data(this,S);if(!a)return D;if(j&&j.timeStamp&&(a.cache.event=j),!b||"option"!==f&&"options"!==f)a[f]&&a[f].apply(a,i);else{if(e===c&&!d.isPlainObject(b))return g=a.get(b),E;a.set(b,e)}}),g!==F?g:this):"object"!=typeof a&&arguments.length?void 0:(k=h(d.extend(D,{},a)),this.each(function(a){var b,c;return c=d.isArray(k.id)?k.id[a]:k.id,c=!c||c===E||c.length<1||y.api[c]?y.nextid++:c,b=r(d(this),c,k),b===E?D:(y.api[c]=b,d.each(R,function(){"initialize"===this.initialize&&this(b)}),void b._assignInitialEvents(j))}))},d.qtip=e,y.api={},d.each({attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&f.options&&"object"==typeof f&&"object"==typeof f.options&&f.options.suppress)return arguments.length<2?d.attr(c,ca):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(ca,b))}return d.fn["attr"+ba].apply(this,arguments)},clone:function(a){var b=d.fn["clone"+ba].apply(this,arguments);return a||b.filter("["+ca+"]").attr("title",function(){return d.attr(this,ca)}).removeAttr(ca),b}},function(a,b){if(!b||d.fn[a+ba])return D;var c=d.fn[a+ba]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+ba]=d.cleanData,d.cleanData=function(a){for(var b,c=0;(b=d(a[c])).length;c++)if(b.attr(T))try{b.triggerHandler("removeqtip")}catch(e){}d["cleanData"+ba].apply(this,arguments)}),y.version="3.0.3",y.nextid=0,y.inactiveEvents=X,y.zindex=15e3,y.defaults={prerender:E,id:E,overwrite:D,suppress:D,content:{text:D,attr:"title",title:E,button:E},position:{my:"top left",at:"bottom right",target:E,container:E,viewport:E,adjust:{x:0,y:0,mouse:D,scroll:D,resize:D,method:"flipinvert flipinvert"},effect:function(a,b){d(this).animate(b,{duration:200,queue:E})}},show:{target:E,event:"mouseenter",effect:D,delay:90,solo:E,ready:E,autofocus:E},hide:{target:E,event:"mouseleave",effect:D,delay:0,fixed:E,inactive:E,leave:"window",distance:E},style:{classes:"",widget:E,width:E,height:E,def:D},events:{render:F,move:F,show:F,hide:F,toggle:F,visible:F,hidden:F,focus:F,blur:F}};var ha,ia,ja,ka,la,ma="margin",na="border",oa="color",pa="background-color",qa="transparent",ra=" !important",sa=!!b.createElement("canvas").getContext,ta=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,ua={},va=["Webkit","O","Moz","ms"];sa?(ka=a.devicePixelRatio||1,la=function(){var a=b.createElement("canvas").getContext("2d");return a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||1}(),ja=ka/la):ia=function(a,b,c){return"'},d.extend(v.prototype,{init:function(a){var b,c;c=this.element=a.elements.tip=d("",{"class":S+"-tip"}).prependTo(a.tooltip),sa?(b=d("").appendTo(this.element)[0].getContext("2d"),b.lineJoin="miter",b.miterLimit=1e5,b.save()):(b=ia("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(b+b),a._bind(d("*",c).add(c),["click","mousedown"],function(a){a.stopPropagation()},this._ns)),a._bind(a.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(a){var b=this.qtip.elements.titlebar;return b&&(a.y===K||a.y===O&&this.element.position().top+this.size[1]/2+this.options.offsetl&&!ta.test(e[1])&&(e[0]=e[1]),this.border=l=p.border!==D?p.border:l):this.border=l=0,k=this.size=this._calculateSize(b),n.css({width:k[0],height:k[1],lineHeight:k[1]+"px"}),j=b.precedance===H?[s(r.x===L?l:r.x===N?k[0]-q[0]-l:(k[0]-q[0])/2),s(r.y===K?k[1]-q[1]:0)]:[s(r.x===L?k[0]-q[0]:0),s(r.y===K?l:r.y===M?k[1]-q[1]-l:(k[1]-q[1])/2)],sa?(g=o[0].getContext("2d"),g.restore(),g.save(),g.clearRect(0,0,6e3,6e3),h=this._calculateTip(r,q,ja),i=this._calculateTip(r,this.size,ja),o.attr(I,k[0]*ja).attr(J,k[1]*ja),o.css(I,k[0]).css(J,k[1]),this._drawCoords(g,i),g.fillStyle=e[1],g.fill(),g.translate(j[0]*ja,j[1]*ja),this._drawCoords(g,h),g.fillStyle=e[0],g.fill()):(h=this._calculateTip(r),h="m"+h[0]+","+h[1]+" l"+h[2]+","+h[3]+" "+h[4]+","+h[5]+" xe",j[2]=l&&/^(r|b)/i.test(b.string())?8===da.ie?2:1:0,o.css({coordsize:k[0]+l+" "+k[1]+l,antialias:""+(r.string().indexOf(O)>-1),left:j[0]-j[2]*Number(f===G),top:j[1]-j[2]*Number(f===H),width:k[0]+l,height:k[1]+l}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k[0]+l+" "+k[1]+l,path:h,fillcolor:e[0],filled:!!a,stroked:!a}).toggle(!(!l&&!a)),!a&&b.html(ia("stroke",'weight="'+2*l+'px" color="'+e[1]+'" miterlimit="1000" joinstyle="miter"'))})),a.opera&&setTimeout(function(){m.tip.css({display:"inline-block",visibility:"visible"})},1),c!==E&&this.calculate(b,k)},calculate:function(a,b){if(!this.enabled)return E;var c,e,f=this,g=this.qtip.elements,h=this.element,i=this.options.offset,j={};
return a=a||this.corner,c=a.precedance,b=b||this._calculateSize(a),e=[a.x,a.y],c===G&&e.reverse(),d.each(e,function(d,e){var h,k,l;e===O?(h=c===H?L:K,j[h]="50%",j[ma+"-"+h]=-Math.round(b[c===H?0:1]/2)+i):(h=f._parseWidth(a,e,g.tooltip),k=f._parseWidth(a,e,g.content),l=f._parseRadius(a),j[e]=Math.max(-f.border,d?k:i+(l>h?l:-h)))}),j[a[c]]-=b[c===G?0:1],h.css({margin:"",top:"",bottom:"",left:"",right:""}).css(j),j},reposition:function(a,b,d){function e(a,b,c,d,e){a===Q&&j.precedance===b&&k[d]&&j[c]!==O?j.precedance=j.precedance===G?H:G:a!==Q&&k[d]&&(j[b]=j[b]===O?k[d]>0?d:e:j[b]===d?e:d)}function f(a,b,e){j[a]===O?p[ma+"-"+b]=o[a]=g[ma+"-"+b]-k[b]:(h=g[e]!==c?[k[b],-g[b]]:[-k[b],g[b]],(o[a]=Math.max(h[0],h[1]))>h[0]&&(d[b]-=k[b],o[b]=E),p[g[e]!==c?e:b]=o[a])}if(this.enabled){var g,h,i=b.cache,j=this.corner.clone(),k=d.adjusted,l=b.options.position.adjust.method.split(" "),m=l[0],n=l[1]||l[0],o={left:E,top:E,x:0,y:0},p={};this.corner.fixed!==D&&(e(m,G,H,L,N),e(n,H,G,K,M),j.string()===i.corner.string()&&i.cornerTop===k.top&&i.cornerLeft===k.left||this.update(j,E)),g=this.calculate(j),g.right!==c&&(g.left=-g.right),g.bottom!==c&&(g.top=-g.bottom),g.user=this.offset,o.left=m===Q&&!!k.left,o.left&&f(G,L,N),o.top=n===Q&&!!k.top,o.top&&f(H,K,M),this.element.css(p).toggle(!(o.x&&o.y||j.x===O&&o.y||j.y===O&&o.x)),d.left-=g.left.charAt?g.user:m!==Q||o.top||!o.left&&!o.top?g.left+this.border:0,d.top-=g.top.charAt?g.user:n!==Q||o.left||!o.left&&!o.top?g.top+this.border:0,i.cornerLeft=k.left,i.cornerTop=k.top,i.corner=j.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),ha=R.tip=function(a){return new v(a,a.options.style.tip)},ha.initialize="render",ha.sanitize=function(a){if(a.style&&"tip"in a.style){var b=a.style.tip;"object"!=typeof b&&(b=a.style.tip={corner:b}),/string|boolean/i.test(typeof b.corner)||(b.corner=D)}},B.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(a){this.size=[a.width,a.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},d.extend(D,y.defaults,{style:{tip:{corner:D,mimic:E,width:6,height:6,border:D,offset:0}}});var wa,xa,ya="qtip-modal",za="."+ya;xa=function(){function a(a){if(d.expr[":"].focusable)return d.expr[":"].focusable;var b,c,e,f=!isNaN(d.attr(a,"tabindex")),g=a.nodeName&&a.nodeName.toLowerCase();return"area"===g?(b=a.parentNode,c=b.name,a.href&&c&&"map"===b.nodeName.toLowerCase()?(e=d("img[usemap=#"+c+"]")[0],!!e&&e.is(":visible")):!1):/input|select|textarea|button|object/.test(g)?!a.disabled:"a"===g?a.href||f:f}function c(a){j.length<1&&a.length?a.not("body").blur():j.first().focus()}function e(a){if(h.is(":visible")){var b,e=d(a.target),g=f.tooltip,i=e.closest(W);b=i.length<1?E:parseInt(i[0].style.zIndex,10)>parseInt(g[0].style.zIndex,10),b||e.closest(W)[0]===g[0]||c(e)}}var f,g,h,i=this,j={};d.extend(i,{init:function(){return h=i.elem=d("",{id:"qtip-overlay",html:"",mousedown:function(){return E}}).hide(),d(b.body).bind("focusin"+za,e),d(b).bind("keydown"+za,function(a){f&&f.options.show.modal.escape&&27===a.keyCode&&f.hide(a)}),h.bind("click"+za,function(a){f&&f.options.show.modal.blur&&f.hide(a)}),i},update:function(b){f=b,j=b.options.show.modal.stealfocus!==E?b.tooltip.find("*").filter(function(){return a(this)}):[]},toggle:function(a,e,j){var k=a.tooltip,l=a.options.show.modal,m=l.effect,n=e?"show":"hide",o=h.is(":visible"),p=d(za).filter(":visible:not(:animated)").not(k);return i.update(a),e&&l.stealfocus!==E&&c(d(":focus")),h.toggleClass("blurs",l.blur),e&&h.appendTo(b.body),h.is(":animated")&&o===e&&g!==E||!e&&p.length?i:(h.stop(D,E),d.isFunction(m)?m.call(h,e):m===E?h[n]():h.fadeTo(parseInt(j,10)||90,e?1:0,function(){e||h.hide()}),e||h.queue(function(a){h.css({left:"",top:""}),d(za).length||h.detach(),a()}),g=e,f.destroyed&&(f=F),i)}}),i.init()},xa=new xa,d.extend(w.prototype,{init:function(a){var b=a.tooltip;return this.options.on?(a.elements.overlay=xa.elem,b.addClass(ya).css("z-index",y.modal_zindex+d(za).length),a._bind(b,["tooltipshow","tooltiphide"],function(a,c,e){var f=a.originalEvent;if(a.target===b[0])if(f&&"tooltiphide"===a.type&&/mouse(leave|enter)/.test(f.type)&&d(f.relatedTarget).closest(xa.elem[0]).length)try{a.preventDefault()}catch(g){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(a,"tooltipshow"===a.type,e)},this._ns,this),a._bind(b,"tooltipfocus",function(a,c){if(!a.isDefaultPrevented()&&a.target===b[0]){var e=d(za),f=y.modal_zindex+e.length,g=parseInt(b[0].style.zIndex,10);xa.elem[0].style.zIndex=f-1,e.each(function(){this.style.zIndex>g&&(this.style.zIndex-=1)}),e.filter("."+$).qtip("blur",a.originalEvent),b.addClass($)[0].style.zIndex=f,xa.update(c);try{a.preventDefault()}catch(h){}}},this._ns,this),void a._bind(b,"tooltiphide",function(a){a.target===b[0]&&d(za).filter(":visible").not(b).last().qtip("focus",a)},this._ns,this)):this},toggle:function(a,b,c){return a&&a.isDefaultPrevented()?this:void xa.toggle(this.qtip,!!b,c)},destroy:function(){this.qtip.tooltip.removeClass(ya),this.qtip._unbind(this.qtip.tooltip,this._ns),xa.toggle(this.qtip,E),delete this.qtip.elements.overlay}}),wa=R.modal=function(a){return new w(a,a.options.show.modal)},wa.sanitize=function(a){a.show&&("object"!=typeof a.show.modal?a.show.modal={on:!!a.show.modal}:"undefined"==typeof a.show.modal.on&&(a.show.modal.on=D))},y.modal_zindex=y.zindex-200,wa.initialize="render",B.modal={"^show.modal.(on|blur)$":function(){this.destroy(),this.init(),this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}},d.extend(D,y.defaults,{show:{modal:{on:E,effect:D,blur:D,stealfocus:D,escape:D}}}),R.viewport=function(c,d,e,f,g,h,i){function j(a,b,c,e,f,g,h,i,j){var k=d[f],s=u[a],t=v[a],w=c===Q,x=s===f?j:s===g?-j:-j/2,y=t===f?i:t===g?-i:-i/2,z=q[f]+r[f]-(n?0:m[f]),A=z-k,B=k+j-(h===I?o:p)-z,C=x-(u.precedance===a||s===u[b]?y:0)-(t===O?i/2:0);return w?(C=(s===f?1:-1)*x,d[f]+=A>0?A:B>0?-B:0,d[f]=Math.max(-m[f]+r[f],k-C,Math.min(Math.max(-m[f]+r[f]+(h===I?o:p),k+C),d[f],"center"===s?k-x:1e9))):(e*=c===P?2:0,A>0&&(s!==f||B>0)?(d[f]-=C+e,l.invert(a,f)):B>0&&(s!==g||A>0)&&(d[f]-=(s===O?-C:C)+e,l.invert(a,g)),d[f]B&&(d[f]=k,l=u.clone())),d[f]-k}var k,l,m,n,o,p,q,r,s=e.target,t=c.elements.tooltip,u=e.my,v=e.at,w=e.adjust,x=w.method.split(" "),y=x[0],z=x[1]||x[0],A=e.viewport,B=e.container,C={left:0,top:0};return A.jquery&&s[0]!==a&&s[0]!==b.body&&"none"!==w.method?(m=B.offset()||C,n="static"===B.css("position"),k="fixed"===t.css("position"),o=A[0]===a?A.width():A.outerWidth(E),p=A[0]===a?A.height():A.outerHeight(E),q={left:k?0:A.scrollLeft(),top:k?0:A.scrollTop()},r=A.offset()||C,"shift"===y&&"shift"===z||(l=u.clone()),C={left:"none"!==y?j(G,H,y,w.x,L,N,I,f,h):0,top:"none"!==z?j(H,G,z,w.y,K,M,J,g,i):0,my:l}):C},R.polys={polygon:function(a,b){var c,d,e,f={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:E},g=0,h=[],i=1,j=1,k=0,l=0;for(g=a.length;g--;)c=[parseInt(a[--g],10),parseInt(a[g+1],10)],c[0]>f.position.right&&(f.position.right=c[0]),c[0]f.position.bottom&&(f.position.bottom=c[1]),c[1]0&&e>0&&i>0&&j>0;)for(d=Math.floor(d/2),e=Math.floor(e/2),b.x===L?i=d:b.x===N?i=f.width-d:i+=Math.floor(d/2),b.y===K?j=e:b.y===M?j=f.height-e:j+=Math.floor(e/2),g=h.length;g--&&!(h.length<2);)k=h[g][0]-f.position.left,l=h[g][1]-f.position.top,(b.x===L&&k>=i||b.x===N&&i>=k||b.x===O&&(i>k||k>f.width-i)||b.y===K&&l>=j||b.y===M&&j>=l||b.y===O&&(j>l||l>f.height-j))&&h.splice(g,1);f.position={left:h[0][0],top:h[0][1]}}return f},rect:function(a,b,c,d){return{width:Math.abs(c-a),height:Math.abs(d-b),position:{left:Math.min(a,c),top:Math.min(b,d)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(a,b,c,d,e){var f=R.polys._angles[e.abbrev()],g=0===f?0:c*Math.cos(f*Math.PI),h=d*Math.sin(f*Math.PI);return{width:2*c-Math.abs(g),height:2*d-Math.abs(h),position:{left:a+g,top:b+h},adjustable:E}},circle:function(a,b,c,d){return R.polys.ellipse(a,b,c,c,d)}},R.svg=function(a,c,e){for(var f,g,h,i,j,k,l,m,n,o=c[0],p=d(o.ownerSVGElement),q=o.ownerDocument,r=(parseInt(c.css("stroke-width"),10)||0)/2;!o.getBBox;)o=o.parentNode;if(!o.getBBox||!o.parentNode)return E;switch(o.nodeName){case"ellipse":case"circle":m=R.polys.ellipse(o.cx.baseVal.value,o.cy.baseVal.value,(o.rx||o.r).baseVal.value+r,(o.ry||o.r).baseVal.value+r,e);break;case"line":case"polygon":case"polyline":for(l=o.points||[{x:o.x1.baseVal.value,y:o.y1.baseVal.value},{x:o.x2.baseVal.value,y:o.y2.baseVal.value}],m=[],k=-1,i=l.numberOfItems||l.length;++k';d.extend(x.prototype,{_scroll:function(){var b=this.qtip.elements.overlay;b&&(b[0].style.top=d(a).scrollTop()+"px")},init:function(c){var e=c.tooltip;d("select, object").length<1&&(this.bgiframe=c.elements.bgiframe=d(Ba).appendTo(e),c._bind(e,"tooltipmove",this.adjustBGIFrame,this._ns,this)),this.redrawContainer=d("",{id:S+"-rcontainer"}).appendTo(b.body),c.elements.overlay&&c.elements.overlay.addClass("qtipmodal-ie6fix")&&(c._bind(a,["scroll","resize"],this._scroll,this._ns,this),c._bind(e,["tooltipshow"],this._scroll,this._ns,this)),this.redraw()},adjustBGIFrame:function(){var a,b,c=this.qtip.tooltip,d={height:c.outerHeight(E),width:c.outerWidth(E)},e=this.qtip.plugins.tip,f=this.qtip.elements.tip;b=parseInt(c.css("borderLeftWidth"),10)||0,b={left:-b,top:-b},e&&f&&(a="x"===e.corner.precedance?[I,L]:[J,K],b[a[1]]-=f[a[0]]()),this.bgiframe.css(b).css(d)},redraw:function(){if(this.qtip.rendered<1||this.drawing)return this;var a,b,c,d,e=this.qtip.tooltip,f=this.qtip.options.style,g=this.qtip.options.position.container;return this.qtip.drawing=1,f.height&&e.css(J,f.height),f.width?e.css(I,f.width):(e.css(I,"").appendTo(this.redrawContainer),b=e.width(),1>b%2&&(b+=1),c=e.css("maxWidth")||"",d=e.css("minWidth")||"",a=(c+d).indexOf("%")>-1?g.width()/100:0,c=(c.indexOf("%")>-1?a:1*parseInt(c,10))||b,d=(d.indexOf("%")>-1?a:1*parseInt(d,10))||0,b=c+d?Math.min(Math.max(b,d),c):b,e.css(I,Math.round(b)).appendTo(g)),this.drawing=0,this},destroy:function(){this.bgiframe&&this.bgiframe.remove(),this.qtip._unbind([a,this.qtip.tooltip],this._ns)}}),Aa=R.ie6=function(a){return 6===da.ie?new x(a):E},Aa.initialize="render",B.ie6={"^content|style$":function(){this.redraw()}}})}(window,document);
;
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function ($, document, undefined) {
var pluses = ..\\http\\+\\MS_7787.html;
function raw(s) {
return s;
}
function decoded(s) {
return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
}
function unRfc2068(value) {
if (value.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape
value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, 'MS_16.html');
}
return value;
}
function fromJSON(value) {
return config.json ? JSON.parse(value) : value;
}
var config = $.cookie = function (key, value, options) {
// write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = config.json ? JSON.stringify(value) : String(value);
return (document.cookie = [
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// read
var decode = config.raw ? raw : decoded;
var cookies = document.cookie.split('; ');
var result = key ? null : {};
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = decode(parts.join('='));
if (key && key === name) {
result = fromJSON(cookie);
break;
}
if (!key) {
result[name] = fromJSON(cookie);
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) !== null) {
$.cookie(key, null, options);
return true;
}
return false;
};
})(jQuery, document);
;
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS = CryptoJS || function (u, p) {
var d = {}, l = d.lib = {}, s = function () { }, t = l.Base = { extend: function (a) { s.prototype = this; var c = new s; a && c.mixIn(a); c.hasOwnProperty("init") || (c.init = function () { c.$super.init.apply(this, arguments) }); c.init.prototype = c; c.$super = this; return c }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } },
r = l.WordArray = t.extend({
init: function (a, c) { a = this.words = a || []; this.sigBytes = c != p ? c : 4 * a.length }, toString: function (a) { return (a || v).stringify(this) }, concat: function (a) { var c = this.words, e = a.words, j = this.sigBytes; a = a.sigBytes; this.clamp(); if (j % 4) for (var k = 0; k < a; k++) c[j + k >>> 2] |= (e[k >>> 2] >>> 24 - 8 * (k % 4) & 255) << 24 - 8 * ((j + k) % 4); else if (65535 < e.length) for (k = 0; k < a; k += 4) c[j + k >>> 2] = e[k >>> 2]; else c.push.apply(c, e); this.sigBytes += a; return this }, clamp: function () {
var a = this.words, c = this.sigBytes; a[c >>> 2] &= 4294967295 <<
32 - 8 * (c % 4); a.length = u.ceil(c / 4)
}, clone: function () { var a = t.clone.call(this); a.words = this.words.slice(0); return a }, random: function (a) { for (var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0); return new r.init(c, a) }
}), w = d.enc = {}, v = w.Hex = {
stringify: function (a) { var c = a.words; a = a.sigBytes; for (var e = [], j = 0; j < a; j++) { var k = c[j >>> 2] >>> 24 - 8 * (j % 4) & 255; e.push((k >>> 4).toString(16)); e.push((k & 15).toString(16)) } return e.join("") }, parse: function (a) {
for (var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j,
2), 16) << 24 - 4 * (j % 8); return new r.init(e, c / 2)
}
}, b = w.Latin1 = { stringify: function (a) { var c = a.words; a = a.sigBytes; for (var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255)); return e.join("") }, parse: function (a) { for (var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4); return new r.init(e, c) } }, x = w.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(b.stringify(a))) } catch (c) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return b.parse(unescape(encodeURIComponent(a))) } },
q = l.BufferedBlockAlgorithm = t.extend({
reset: function () { this._data = new r.init; this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = x.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var c = this._data, e = c.words, j = c.sigBytes, k = this.blockSize, b = j / (4 * k), b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0); a = b * k; j = u.min(4 * a, j); if (a) { for (var q = 0; q < a; q += k) this._doProcessBlock(e, q); q = e.splice(0, a); c.sigBytes -= j } return new r.init(q, j) }, clone: function () {
var a = t.clone.call(this);
a._data = this._data.clone(); return a
}, _minBufferSize: 0
}); l.Hasher = q.extend({
cfg: t.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { q.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._doFinalize() }, blockSize: 16, _createHelper: function (a) { return function (b, e) { return (new a.init(e)).finalize(b) } }, _createHmacHelper: function (a) {
return function (b, e) {
return (new n.HMAC.init(a,
e)).finalize(b)
}
}
}); var n = d.algo = {}; return d
}(Math);
(function () {
var u = CryptoJS, p = u.lib.WordArray; u.enc.Base64 = {
stringify: function (d) { var l = d.words, p = d.sigBytes, t = this._map; d.clamp(); d = []; for (var r = 0; r < p; r += 3) for (var w = (l[r >>> 2] >>> 24 - 8 * (r % 4) & 255) << 16 | (l[r + 1 >>> 2] >>> 24 - 8 * ((r + 1) % 4) & 255) << 8 | l[r + 2 >>> 2] >>> 24 - 8 * ((r + 2) % 4) & 255, v = 0; 4 > v && r + 0.75 * v < p; v++) d.push(t.charAt(w >>> 6 * (3 - v) & 63)); if (l = t.charAt(64)) for (; d.length % 4;) d.push(l); return d.join("") }, parse: function (d) {
var l = d.length, s = this._map, t = s.charAt(64); t && (t = d.indexOf(t), -1 != t && (l = t)); for (var t = [], r = 0, w = 0; w <
l; w++) if (w % 4) { var v = s.indexOf(d.charAt(w - 1)) << 2 * (w % 4), b = s.indexOf(d.charAt(w)) >>> 6 - 2 * (w % 4); t[r >>> 2] |= (v | b) << 24 - 8 * (r % 4); r++ } return p.create(t, r)
}, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
})();
(function (u) {
function p(b, n, a, c, e, j, k) { b = b + (n & a | ~n & c) + e + k; return (b << j | b >>> 32 - j) + n } function d(b, n, a, c, e, j, k) { b = b + (n & c | a & ~c) + e + k; return (b << j | b >>> 32 - j) + n } function l(b, n, a, c, e, j, k) { b = b + (n ^ a ^ c) + e + k; return (b << j | b >>> 32 - j) + n } function s(b, n, a, c, e, j, k) { b = b + (a ^ (n | ~c)) + e + k; return (b << j | b >>> 32 - j) + n } for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0; r = r.MD5 = v.extend({
_doReset: function () { this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878]) },
_doProcessBlock: function (q, n) {
for (var a = 0; 16 > a; a++) { var c = n + a, e = q[c]; q[c] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360 } var a = this._hash.words, c = q[n + 0], e = q[n + 1], j = q[n + 2], k = q[n + 3], z = q[n + 4], r = q[n + 5], t = q[n + 6], w = q[n + 7], v = q[n + 8], A = q[n + 9], B = q[n + 10], C = q[n + 11], u = q[n + 12], D = q[n + 13], E = q[n + 14], x = q[n + 15], f = a[0], m = a[1], g = a[2], h = a[3], f = p(f, m, g, h, c, 7, b[0]), h = p(h, f, m, g, e, 12, b[1]), g = p(g, h, f, m, j, 17, b[2]), m = p(m, g, h, f, k, 22, b[3]), f = p(f, m, g, h, z, 7, b[4]), h = p(h, f, m, g, r, 12, b[5]), g = p(g, h, f, m, t, 17, b[6]), m = p(m, g, h, f, w, 22, b[7]),
f = p(f, m, g, h, v, 7, b[8]), h = p(h, f, m, g, A, 12, b[9]), g = p(g, h, f, m, B, 17, b[10]), m = p(m, g, h, f, C, 22, b[11]), f = p(f, m, g, h, u, 7, b[12]), h = p(h, f, m, g, D, 12, b[13]), g = p(g, h, f, m, E, 17, b[14]), m = p(m, g, h, f, x, 22, b[15]), f = d(f, m, g, h, e, 5, b[16]), h = d(h, f, m, g, t, 9, b[17]), g = d(g, h, f, m, C, 14, b[18]), m = d(m, g, h, f, c, 20, b[19]), f = d(f, m, g, h, r, 5, b[20]), h = d(h, f, m, g, B, 9, b[21]), g = d(g, h, f, m, x, 14, b[22]), m = d(m, g, h, f, z, 20, b[23]), f = d(f, m, g, h, A, 5, b[24]), h = d(h, f, m, g, E, 9, b[25]), g = d(g, h, f, m, k, 14, b[26]), m = d(m, g, h, f, v, 20, b[27]), f = d(f, m, g, h, D, 5, b[28]), h = d(h, f,
m, g, j, 9, b[29]), g = d(g, h, f, m, w, 14, b[30]), m = d(m, g, h, f, u, 20, b[31]), f = l(f, m, g, h, r, 4, b[32]), h = l(h, f, m, g, v, 11, b[33]), g = l(g, h, f, m, C, 16, b[34]), m = l(m, g, h, f, E, 23, b[35]), f = l(f, m, g, h, e, 4, b[36]), h = l(h, f, m, g, z, 11, b[37]), g = l(g, h, f, m, w, 16, b[38]), m = l(m, g, h, f, B, 23, b[39]), f = l(f, m, g, h, D, 4, b[40]), h = l(h, f, m, g, c, 11, b[41]), g = l(g, h, f, m, k, 16, b[42]), m = l(m, g, h, f, t, 23, b[43]), f = l(f, m, g, h, A, 4, b[44]), h = l(h, f, m, g, u, 11, b[45]), g = l(g, h, f, m, x, 16, b[46]), m = l(m, g, h, f, j, 23, b[47]), f = s(f, m, g, h, c, 6, b[48]), h = s(h, f, m, g, w, 10, b[49]), g = s(g, h, f, m,
E, 15, b[50]), m = s(m, g, h, f, r, 21, b[51]), f = s(f, m, g, h, u, 6, b[52]), h = s(h, f, m, g, k, 10, b[53]), g = s(g, h, f, m, B, 15, b[54]), m = s(m, g, h, f, e, 21, b[55]), f = s(f, m, g, h, v, 6, b[56]), h = s(h, f, m, g, x, 10, b[57]), g = s(g, h, f, m, t, 15, b[58]), m = s(m, g, h, f, D, 21, b[59]), f = s(f, m, g, h, z, 6, b[60]), h = s(h, f, m, g, C, 10, b[61]), g = s(g, h, f, m, j, 15, b[62]), m = s(m, g, h, f, A, 21, b[63]); a[0] = a[0] + f | 0; a[1] = a[1] + m | 0; a[2] = a[2] + g | 0; a[3] = a[3] + h | 0
}, _doFinalize: function () {
var b = this._data, n = b.words, a = 8 * this._nDataBytes, c = 8 * b.sigBytes; n[c >>> 5] |= 128 << 24 - c % 32; var e = u.floor(a /
4294967296); n[(c + 64 >>> 9 << 4) + 15] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360; n[(c + 64 >>> 9 << 4) + 14] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360; b.sigBytes = 4 * (n.length + 1); this._process(); b = this._hash; n = b.words; for (a = 0; 4 > a; a++) c = n[a], n[a] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360; return b
}, clone: function () { var b = v.clone.call(this); b._hash = this._hash.clone(); return b }
}); t.MD5 = v._createHelper(r); t.HmacMD5 = v._createHmacHelper(r)
})(Math);
(function () {
var u = CryptoJS, p = u.lib, d = p.Base, l = p.WordArray, p = u.algo, s = p.EvpKDF = d.extend({ cfg: d.extend({ keySize: 4, hasher: p.MD5, iterations: 1 }), init: function (d) { this.cfg = this.cfg.extend(d) }, compute: function (d, r) { for (var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) { n && s.update(n); var n = s.update(d).finalize(r); s.reset(); for (var a = 1; a < p; a++) n = s.finalize(n), s.reset(); b.concat(n) } b.sigBytes = 4 * q; return b } }); u.EvpKDF = function (d, l, p) {
return s.create(p).compute(d,
l)
}
})();
CryptoJS.lib.Cipher || function (u) {
var p = CryptoJS, d = p.lib, l = d.Base, s = d.WordArray, t = d.BufferedBlockAlgorithm, r = p.enc.Base64, w = p.algo.EvpKDF, v = d.Cipher = t.extend({
cfg: l.extend(), createEncryptor: function (e, a) { return this.create(this._ENC_XFORM_MODE, e, a) }, createDecryptor: function (e, a) { return this.create(this._DEC_XFORM_MODE, e, a) }, init: function (e, a, b) { this.cfg = this.cfg.extend(b); this._xformMode = e; this._key = a; this.reset() }, reset: function () { t.reset.call(this); this._doReset() }, process: function (e) { this._append(e); return this._process() },
finalize: function (e) { e && this._append(e); return this._doFinalize() }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function (e) { return { encrypt: function (b, k, d) { return ("string" == typeof k ? c : a).encrypt(e, b, k, d) }, decrypt: function (b, k, d) { return ("string" == typeof k ? c : a).decrypt(e, b, k, d) } } }
}); d.StreamCipher = v.extend({ _doFinalize: function () { return this._process(!0) }, blockSize: 1 }); var b = p.mode = {}, x = function (e, a, b) {
var c = this._iv; c ? this._iv = u : c = this._prevBlock; for (var d = 0; d < b; d++) e[a + d] ^=
c[d]
}, q = (d.BlockCipherMode = l.extend({ createEncryptor: function (e, a) { return this.Encryptor.create(e, a) }, createDecryptor: function (e, a) { return this.Decryptor.create(e, a) }, init: function (e, a) { this._cipher = e; this._iv = a } })).extend(); q.Encryptor = q.extend({ processBlock: function (e, a) { var b = this._cipher, c = b.blockSize; x.call(this, e, a, c); b.encryptBlock(e, a); this._prevBlock = e.slice(a, a + c) } }); q.Decryptor = q.extend({
processBlock: function (e, a) {
var b = this._cipher, c = b.blockSize, d = e.slice(a, a + c); b.decryptBlock(e, a); x.call(this,
e, a, c); this._prevBlock = d
}
}); b = b.CBC = q; q = (p.pad = {}).Pkcs7 = { pad: function (a, b) { for (var c = 4 * b, c = c - a.sigBytes % c, d = c << 24 | c << 16 | c << 8 | c, l = [], n = 0; n < c; n += 4) l.push(d); c = s.create(l, c); a.concat(c) }, unpad: function (a) { a.sigBytes -= a.words[a.sigBytes - 1 >>> 2] & 255 } }; d.BlockCipher = v.extend({
cfg: v.cfg.extend({ mode: b, padding: q }), reset: function () {
v.reset.call(this); var a = this.cfg, b = a.iv, a = a.mode; if (this._xformMode == this._ENC_XFORM_MODE) var c = a.createEncryptor; else c = a.createDecryptor, this._minBufferSize = 1; this._mode = c.call(a,
this, b && b.words)
}, _doProcessBlock: function (a, b) { this._mode.processBlock(a, b) }, _doFinalize: function () { var a = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { a.pad(this._data, this.blockSize); var b = this._process(!0) } else b = this._process(!0), a.unpad(b); return b }, blockSize: 4
}); var n = d.CipherParams = l.extend({ init: function (a) { this.mixIn(a) }, toString: function (a) { return (a || this.formatter).stringify(this) } }), b = (p.format = {}).OpenSSL = {
stringify: function (a) {
var b = a.ciphertext; a = a.salt; return (a ? s.create([1398893684,
1701076831]).concat(a).concat(b) : b).toString(r)
}, parse: function (a) { a = r.parse(a); var b = a.words; if (1398893684 == b[0] && 1701076831 == b[1]) { var c = s.create(b.slice(2, 4)); b.splice(0, 4); a.sigBytes -= 16 } return n.create({ ciphertext: a, salt: c }) }
}, a = d.SerializableCipher = l.extend({
cfg: l.extend({ format: b }), encrypt: function (a, b, c, d) { d = this.cfg.extend(d); var l = a.createEncryptor(c, d); b = l.finalize(b); l = l.cfg; return n.create({ ciphertext: b, key: c, iv: l.iv, algorithm: a, mode: l.mode, padding: l.padding, blockSize: a.blockSize, formatter: d.format }) },
decrypt: function (a, b, c, d) { d = this.cfg.extend(d); b = this._parse(b, d.format); return a.createDecryptor(c, d).finalize(b.ciphertext) }, _parse: function (a, b) { return "string" == typeof a ? b.parse(a, this) : a }
}), p = (p.kdf = {}).OpenSSL = { execute: function (a, b, c, d) { d || (d = s.random(8)); a = w.create({ keySize: b + c }).compute(a, d); c = s.create(a.words.slice(b), 4 * c); a.sigBytes = 4 * b; return n.create({ key: a, iv: c, salt: d }) } }, c = d.PasswordBasedCipher = a.extend({
cfg: a.cfg.extend({ kdf: p }), encrypt: function (b, c, d, l) {
l = this.cfg.extend(l); d = l.kdf.execute(d,
b.keySize, b.ivSize); l.iv = d.iv; b = a.encrypt.call(this, b, c, d.key, l); b.mixIn(d); return b
}, decrypt: function (b, c, d, l) { l = this.cfg.extend(l); c = this._parse(c, l.format); d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt); l.iv = d.iv; return a.decrypt.call(this, b, c, d.key, l) }
})
}();
(function () {
for (var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) a[c] = 128 > c ? c << 1 : c << 1 ^ 283; for (var e = 0, j = 0, c = 0; 256 > c; c++) { var k = j ^ j << 1 ^ j << 2 ^ j << 3 ^ j << 4, k = k >>> 8 ^ k & 255 ^ 99; l[e] = k; s[k] = e; var z = a[e], F = a[z], G = a[F], y = 257 * a[k] ^ 16843008 * k; t[e] = y << 24 | y >>> 8; r[e] = y << 16 | y >>> 16; w[e] = y << 8 | y >>> 24; v[e] = y; y = 16843009 * G ^ 65537 * F ^ 257 * z ^ 16843008 * e; b[k] = y << 24 | y >>> 8; x[k] = y << 16 | y >>> 16; q[k] = y << 8 | y >>> 24; n[k] = y; e ? (e = z ^ a[a[a[G ^ z]]], j ^= a[a[j]]) : e = j = 1 } var H = [0, 1, 2, 4, 8,
16, 32, 64, 128, 27, 54], d = d.AES = p.extend({
_doReset: function () {
for (var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = this._keySchedule = [], j = 0; j < a; j++) if (j < d) e[j] = c[j]; else { var k = e[j - 1]; j % d ? 6 < d && 4 == j % d && (k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255]) : (k = k << 8 | k >>> 24, k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255], k ^= H[j / d | 0] << 24); e[j] = e[j - d] ^ k } c = this._invKeySchedule = []; for (d = 0; d < a; d++) j = a - d, k = d % 4 ? e[j] : e[j - 4], c[d] = 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[k >>> 16 & 255]] ^ q[l[k >>>
8 & 255]] ^ n[l[k & 255]]
}, encryptBlock: function (a, b) { this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l) }, decryptBlock: function (a, c) { var d = a[c + 1]; a[c + 1] = a[c + 3]; a[c + 3] = d; this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s); d = a[c + 1]; a[c + 1] = a[c + 3]; a[c + 3] = d }, _doCryptBlock: function (a, b, c, d, e, j, l, f) {
for (var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) var q = d[g >>> 24] ^ e[h >>> 16 & 255] ^ j[k >>> 8 & 255] ^ l[n & 255] ^ c[p++], s = d[h >>> 24] ^ e[k >>> 16 & 255] ^ j[n >>> 8 & 255] ^ l[g & 255] ^ c[p++], t =
d[k >>> 24] ^ e[n >>> 16 & 255] ^ j[g >>> 8 & 255] ^ l[h & 255] ^ c[p++], n = d[n >>> 24] ^ e[g >>> 16 & 255] ^ j[h >>> 8 & 255] ^ l[k & 255] ^ c[p++], g = q, h = s, k = t; q = (f[g >>> 24] << 24 | f[h >>> 16 & 255] << 16 | f[k >>> 8 & 255] << 8 | f[n & 255]) ^ c[p++]; s = (f[h >>> 24] << 24 | f[k >>> 16 & 255] << 16 | f[n >>> 8 & 255] << 8 | f[g & 255]) ^ c[p++]; t = (f[k >>> 24] << 24 | f[n >>> 16 & 255] << 16 | f[g >>> 8 & 255] << 8 | f[h & 255]) ^ c[p++]; n = (f[n >>> 24] << 24 | f[g >>> 16 & 255] << 16 | f[h >>> 8 & 255] << 8 | f[k & 255]) ^ c[p++]; a[b] = q; a[b + 1] = s; a[b + 2] = t; a[b + 3] = n
}, keySize: 8
}); u.AES = p._createHelper(d)
})();;
// http://code.accursoft.com/caret - 1.3.3
!function (e) { e.fn.caret = function (e) { var t = this[0], n = "true" === t.contentEditable; if (0 == arguments.length) { if (window.getSelection) { if (n) { t.focus(); var o = window.getSelection().getRangeAt(0), r = o.cloneRange(); return r.selectNodeContents(t), r.setEnd(o.endContainer, o.endOffset), r.toString().length } return t.selectionStart } if (document.selection) { if (t.focus(), n) { var o = document.selection.createRange(), r = document.body.createTextRange(); return r.moveToElementText(t), r.setEndPoint("EndToEnd", o), r.text.length } var e = 0, c = t.createTextRange(), r = document.selection.createRange().duplicate(), a = r.getBookmark(); for (c.moveToBookmark(a) ; 0 !== c.moveStart("character", -1) ;) e++; return e } return t.selectionStart ? t.selectionStart : 0 } if (-1 == e && (e = this[n ? "text" : "val"]().length), window.getSelection) n ? (t.focus(), window.getSelection().collapse(t.firstChild, e)) : t.setSelectionRange(e, e); else if (document.body.createTextRange) if (n) { var c = document.body.createTextRange(); c.moveToElementText(t), c.moveStart("character", e), c.collapse(!0), c.select() } else { var c = t.createTextRange(); c.move("character", e), c.select() } return n || t.focus(), e } }(jQuery);
/*
jQuery tagEditor v1.0.20
Copyright (c) 2014 Simon Steinberger / Pixabay
GitHub: https://github.com/Pixabay/jQuery-tagEditor
License: http://www.opensource.org/licenses/mit-license.php
*/
(function($){
// auto grow input (stackoverflow.com/questions/931207)
$.fn.tagEditorInput=function(){var t=" ",e=$(this),n=parseInt(e.css("fontSize")),i=$("").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:e.css("fontSize"),fontFamily:e.css("fontFamily"),fontWeight:e.css("fontWeight"),letterSpacing:e.css("letterSpacing"),whiteSpace:"nowrap"}),s=function(){if(t!==(t=e.val())){i.text(t);var s=i.width()+n;20>s&&(s=20),s!=e.width()&&e.width(s)}};return i.insertAfter(e),e.bind("keyup keydown focus",s)};
// plugin with val as parameter for public methods
$.fn.tagEditor = function(options, val, blur){
// helper
function escape(tag) {
return tag.replace(/&/g, "&").replace(//g, ">").replace(..\\index.html"/g, """).replace(..\\index.html'/g, "'");
}
// build options dictionary with default values
var blur_result, o = $.extend({}, $.fn.tagEditor.defaults, options), selector = this;
// store regex and default delimiter in options for later use
o.dregex = new RegExp('['+o.delimiter.replace('-', '\-')+']', 'g');
// public methods
if (typeof options == 'string') {
// depending on selector, response may contain tag lists of multiple editor instances
var response = [];
selector.each(function(){
// the editor is the next sibling to the hidden, original field
var el = $(this), o = el.data('options'), ed = el.next('.tag-editor');
if (options == 'getTags')
response.push({field: el[0], editor: ed, tags: ed.data('tags')});
else if (options == 'addTag') {
if (o.maxTags && ed.data('tags').length >= o.maxTags) return false;
// insert new tag
$(' '+o.delimiter[0]+'
').appendTo(ed).find('.tag-editor-tag')
.html('').addClass('active').find('input').val(val).blur();
if (!blur) ed.click();
else $('.placeholder', ed).remove();
} else if (options == 'removeTag') {
// trigger delete on matching tag, then click editor to create a new tag
$('.tag-editor-tag', ed).filter(function(){return $(this).text()==val;}).closest('li').find('.tag-editor-delete').click();
if (!blur) ed.click();
} else if (options == 'destroy') {
el.removeClass('tag-editor-hidden-src').removeData('options').off('focus.tag-editor').next('.tag-editor').remove();
}
});
return options == 'getTags' ? response : this;
}
// delete selected tags on backspace, delete, ctrl+x
if (window.getSelection) $(document).off('keydown.tag-editor').on('keydown.tag-editor', function(e){
if (e.which == 8 || e.which == 46 || e.ctrlKey && e.which == 88) {
try {
var sel = getSelection(), el = document.activeElement.tagName == 'BODY' ? $(sel.getRangeAt(0).startContainer.parentNode).closest('.tag-editor') : 0;
} catch(e){ el = 0; }
if (sel.rangeCount > 0 && el && el.length) {
var tags = [], splits = sel.toString().split(el.prev().data('options').dregex);
for (i=0; i
').insertAfter(el);
el.addClass('tag-editor-hidden-src') // hide original field
.data('options', o) // set data on hidden field
.on('focus.tag-editor', function(){ ed.click(); }); // simulate tabindex
// add dummy item for min-height on empty editor
ed.append('
');
// markup for new tag
var new_tag = '
'+o.delimiter[0]+'
';
// helper: update global data
function set_placeholder(){
if (o.placeholder && !tag_list.length && !$('.deleted, .placeholder, input', ed).length)
ed.append('
'+o.placeholder+'
');
}
// helper: update global data
function update_globals(init){
var old_tags = tag_list.toString();
tag_list = $('.tag-editor-tag:not(.deleted)', ed).map(function(i, e) {
var val = $.trim($(this).hasClass('active') ? $(this).find('input').val() : $(e).text());
if (val) return val;
}).get();
ed.data('tags', tag_list);
el.val(tag_list.join(o.delimiter[0]));
// change callback except for plugin init
if (!init) if (old_tags != tag_list.toString()) o.onChange(el, ed, tag_list);
set_placeholder();
}
ed.click(function(e, closest_tag){
var d, dist = 99999, loc;
// do not create tag when user selects tags by text selection
if (window.getSelection && getSelection() != '') return;
if (o.maxTags && ed.data('tags').length >= o.maxTags) { ed.find('input').blur(); return false; }
blur_result = true
$('input:focus', ed).blur();
if (!blur_result) return false;
blur_result = true
// always remove placeholder on click
$('.placeholder', ed).remove();
if (closest_tag && closest_tag.length)
loc = 'before';
else {
// calculate tag closest to click position
$('.tag-editor-tag', ed).each(function(){
var tag = $(this), to = tag.offset(), tag_x = to.left, tag_y = to.top;
if (e.pageY >= tag_y && e.pageY <= tag_y+tag.height()) {
if (e.pageX < tag_x) loc = 'before', d = tag_x - e.pageX;
else loc = 'after', d = e.pageX - tag_x - tag.width();
if (d < dist) dist = d, closest_tag = tag;
}
});
}
if (loc == 'before') {
$(new_tag).insertBefore(closest_tag.closest('li')).find('.tag-editor-tag').click();
} else if (loc == 'after')
$(new_tag).insertAfter(closest_tag.closest('li')).find('.tag-editor-tag').click();
else // empty editor
$(new_tag).appendTo(ed).find('.tag-editor-tag').click();
return false;
});
ed.on('click', '.tag-editor-delete', function(e){
// delete icon is hidden when input is visible; place cursor near invisible delete icon on click
if ($(this).prev().hasClass('active')) { $(this).closest('li').find('input').caret(-1); return false; }
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
update_globals();
return false;
});
// delete on right mouse click or ctrl+click
if (o.clickDelete)
ed.on('mousedown', '.tag-editor-tag', function(e){
if (e.ctrlKey || e.which > 1) {
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
update_globals();
return false;
}
});
ed.on('click', '.tag-editor-tag', function(e){
// delete on right click or ctrl+click -> exit
if (o.clickDelete && (e.ctrlKey || e.which > 1)) return false;
if (!$(this).hasClass('active')) {
var tag = $(this).text();
// guess cursor position in text input
var left_percent = Math.abs(($(this).offset().left - e.pageX)/$(this).width()), caret_pos = parseInt(tag.length*left_percent),
input = $(this).html('
').addClass('active').find('input');
input.data('old_tag', tag).tagEditorInput().focus().caret(caret_pos);
if (o.autocomplete) {
var aco = $.extend({}, o.autocomplete);
// extend user provided autocomplete select method
var ac_select = 'select' in aco ? o.autocomplete.select : '';
aco.select = function(e, ui){ if (ac_select) ac_select(e, ui); setTimeout(function(){
ed.trigger('click', [$('.active', ed).find('input').closest('li').next('li').find('.tag-editor-tag')]);
}, 20); };
input.autocomplete(aco);
}
}
return false;
});
// helper: split into multiple tags, e.g. after paste
function split_cleanup(input){
var li = input.closest('li'), sub_tags = input.val().replace(/ +/, ' ').split(o.dregex),
old_tag = input.data('old_tag'), old_tags = tag_list.slice(0), exceeded = false, cb_val; // copy tag_list
for (var i=0; i
'+o.delimiter[0]+'
'+escape(tag)+'
');
if (o.maxTags && old_tags.length >= o.maxTags) { exceeded = true; break; }
}
input.attr('maxlength', o.maxLength).removeData('old_tag').val('')
if (exceeded) input.blur(); else input.focus();
update_globals();
}
ed.on('blur', 'input', function(e){
e.stopPropagation();
var input = $(this), old_tag = input.data('old_tag'), tag = $.trim(input.val().replace(/ +/, ' ').replace(o.dregex, o.delimiter[0]));
if (!tag) {
if (old_tag && o.beforeTagDelete(el, ed, tag_list, old_tag) === false) {
input.val(old_tag).focus();
blur_result = false;
update_globals();
return;
}
try { input.closest('li').remove(); } catch(e){}
if (old_tag) update_globals();
}
else if (tag.indexOf(o.delimiter[0])>=0) { split_cleanup(input); return; }
else if (tag != old_tag) {
if (o.forceLowercase) tag = tag.toLowerCase();
cb_val = o.beforeTagSave(el, ed, tag_list, old_tag, tag);
tag = cb_val || tag;
if (cb_val === false) {
if (old_tag) {
input.val(old_tag).focus();
blur_result = false;
update_globals();
return;
}
try { input.closest('li').remove(); } catch(e){}
if (old_tag) update_globals();
}
// remove duplicates
else if (o.removeDuplicates)
$('.tag-editor-tag:not(.active)', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
}
input.parent().html(escape(tag)).removeClass('active');
if (tag != old_tag) update_globals();
set_placeholder();
});
var pasted_content;
ed.on('paste', 'input', function(e){
$(this).removeAttr('maxlength');
pasted_content = $(this);
setTimeout(function(){ split_cleanup(pasted_content); }, 30);
});
// keypress delimiter
var inp;
ed.on('keypress', 'input', function(e){
if (o.delimiter.indexOf(String.fromCharCode(e.which))>=0) {
inp = $(this);
setTimeout(function(){ split_cleanup(inp); }, 20);
}
});
ed.on('keydown', 'input', function(e){
var $t = $(this);
// left/up key + backspace key on empty field
if ((e.which == 37 || !o.autocomplete && e.which == 38) && !$t.caret() || e.which == 8 && !$t.val()) {
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
if (prev_tag.length) prev_tag.click().find('input').caret(-1);
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
return false;
}
// right/down key
else if ((e.which == 39 || !o.autocomplete && e.which == 40) && ($t.caret() == $t.val().length)) {
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
if (next_tag.length) next_tag.click().find('input').caret(0);
else if ($t.val()) ed.click();
return false;
}
// tab key
else if (e.which == 9) {
// shift+tab
if (e.shiftKey) {
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
if (prev_tag.length) prev_tag.click().find('input').caret(0);
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
// allow tabbing to previous element
else {
el.attr('disabled', 'disabled');
setTimeout(function(){ el.removeAttr('disabled'); }, 30);
return;
}
return false;
// tab
} else {
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
if (next_tag.length) next_tag.click().find('input').caret(0);
else if ($t.val()) ed.click();
else return; // allow tabbing to next element
return false;
}
}
// del key
else if (e.which == 46 && (!$.trim($t.val()) || ($t.caret() == $t.val().length))) {
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
if (next_tag.length) next_tag.click().find('input').caret(0);
else if ($t.val()) ed.click();
return false;
}
// enter key
else if (e.which == 13) {
ed.trigger('click', [$t.closest('li').next('li').find('.tag-editor-tag')]);
// trigger blur if maxTags limit is reached
if (o.maxTags && ed.data('tags').length >= o.maxTags) ed.find('input').blur();
return false;
}
// pos1
else if (e.which == 36 && !$t.caret()) ed.find('.tag-editor-tag').first().click();
// end
else if (e.which == 35 && $t.caret() == $t.val().length) ed.find('.tag-editor-tag').last().click();
// esc
else if (e.which == 27) {
$t.val($t.data('old_tag') ? $t.data('old_tag') : '').blur();
return false;
}
});
// create initial tags
var tags = o.initialTags.length ? o.initialTags : el.val().split(o.dregex);
for (var i=0; i= o.maxTags) break;
var tag = $.trim(tags[i].replace(/ +/, ' '));
if (tag) {
if (o.forceLowercase) tag = tag.toLowerCase();
tag_list.push(tag);
ed.append(' '+o.delimiter[0]+'
'+escape(tag)+'
');
}
}
update_globals(true); // true -> no onChange callback
// init sortable
if (o.sortable && $.fn.sortable) ed.sortable({
distance: 5, cancel: '.tag-editor-spacer, input', helper: 'clone',
update: function(){ update_globals(); }
});
});
};
$.fn.tagEditor.defaults = {
initialTags: [],
maxTags: 0,
maxLength: 50,
delimiter: ',;',
placeholder: '',
forceLowercase: true,
removeDuplicates: true,
clickDelete: false,
animateDelete: 175,
sortable: true, // jQuery UI sortable
autocomplete: null, // options dict for jQuery UI autocomplete
// callbacks
onChange: function(){},
beforeTagSave: function(){},
beforeTagDelete: function(){}
};
}(jQuery));
;
/* globals define, module, jQuery */
/*
* Mailcheck https://github.com/mailcheck/mailcheck
* Author
* Derrick Ko (@derrickko)
*
* Released under the MIT License.
*
* v 1.1.2
*/
var Mailcheck = {
domainThreshold: 2,
secondLevelThreshold: 2,
topLevelThreshold: 2,
defaultDomains: ['msn.com', 'bellsouth.net',
'telus.net', 'comcast.net', 'optusnet.com.au',
'earthlink.net', 'qq.com', 'sky.com', 'icloud.com',
'mac.com', 'sympatico.ca', 'googlemail.com',
'att.net', 'xtra.co.nz', 'web.de',
'cox.net', 'gmail.com', 'ymail.com',
'aim.com', 'rogers.com', 'verizon.net',
'rocketmail.com', 'google.com', 'optonline.net',
'sbcglobal.net', 'aol.com', 'me.com', 'btinternet.com',
'charter.net', 'shaw.ca','gwl.ca'],
defaultSecondLevelDomains: ["yahoo", "hotmail", "mail", "live", "outlook", "gmx"],
defaultTopLevelDomains: ["com", "com.au", "com.tw", "ca", "co.nz", "co.uk", "de",
"fr", "it", "ru", "net", "org", "edu", "gov", "jp", "nl", "kr", "se", "eu",
"ie", "co.il", "us", "at", "be", "dk", "hk", "es", "gr", "ch", "no", "cz",
"in", "net", "net.au", "info", "biz", "mil", "co.jp", "sg", "hu", "uk", "co.za","com.ph"],
run: function(opts) {
opts.domains = opts.domains || Mailcheck.defaultDomains;
opts.secondLevelDomains = opts.secondLevelDomains || Mailcheck.defaultSecondLevelDomains;
opts.topLevelDomains = opts.topLevelDomains || Mailcheck.defaultTopLevelDomains;
opts.distanceFunction = opts.distanceFunction || Mailcheck.sift4Distance;
var defaultCallback = function(result){ return result; };
var suggestedCallback = opts.suggested || defaultCallback;
var emptyCallback = opts.empty || defaultCallback;
var result = Mailcheck.suggest(Mailcheck.encodeEmail(opts.email), opts.domains, opts.secondLevelDomains, opts.topLevelDomains, opts.distanceFunction);
return result ? suggestedCallback(result) : emptyCallback();
},
suggest: function(email, domains, secondLevelDomains, topLevelDomains, distanceFunction) {
email = email.toLowerCase();
var emailParts = this.splitEmail(email);
if (secondLevelDomains && topLevelDomains) {
// If the email is a valid 2nd-level + top-level, do not suggest anything.
if (secondLevelDomains.indexOf(emailParts.secondLevelDomain) !== -1 && topLevelDomains.indexOf(emailParts.topLevelDomain) !== -1) {
return false;
}
}
var closestDomain = this.findClosestDomain(emailParts.domain, domains, distanceFunction, this.domainThreshold);
if (closestDomain) {
if (closestDomain == emailParts.domain) {
// The email address exactly matches one of the supplied domains; do not return a suggestion.
return false;
} else {
// The email address closely matches one of the supplied domains; return a suggestion
return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
}
}
// The email address does not closely match one of the supplied domains
var closestSecondLevelDomain = this.findClosestDomain(emailParts.secondLevelDomain, secondLevelDomains, distanceFunction, this.secondLevelThreshold);
var closestTopLevelDomain = this.findClosestDomain(emailParts.topLevelDomain, topLevelDomains, distanceFunction, this.topLevelThreshold);
if (emailParts.domain) {
closestDomain = emailParts.domain;
var rtrn = false;
if(closestSecondLevelDomain && closestSecondLevelDomain != emailParts.secondLevelDomain) {
// The email address may have a mispelled second-level domain; return a suggestion
closestDomain = closestDomain.replace(emailParts.secondLevelDomain, closestSecondLevelDomain);
rtrn = true;
}
if(closestTopLevelDomain && closestTopLevelDomain != emailParts.topLevelDomain && emailParts.secondLevelDomain !== '') {
// The email address may have a mispelled top-level domain; return a suggestion
closestDomain = closestDomain.replace(new RegExp(emailParts.topLevelDomain + "$"), closestTopLevelDomain);
rtrn = true;
}
if (rtrn) {
return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
}
}
/* The email address exactly matches one of the supplied domains, does not closely
* match any domain and does not appear to simply have a mispelled top-level domain,
* or is an invalid email address; do not return a suggestion.
*/
return false;
},
findClosestDomain: function(domain, domains, distanceFunction, threshold) {
threshold = threshold || this.topLevelThreshold;
var dist;
var minDist = Infinity;
var closestDomain = null;
if (!domain || !domains) {
return false;
}
if(!distanceFunction) {
distanceFunction = this.sift4Distance;
}
for (var i = 0; i < domains.length; i++) {
if (domain === domains[i]) {
return domain;
}
dist = distanceFunction(domain, domains[i]);
if (dist < minDist) {
minDist = dist;
closestDomain = domains[i];
}
}
if (minDist <= threshold && closestDomain !== null) {
return closestDomain;
} else {
return false;
}
},
sift4Distance: function(s1, s2, maxOffset) {
// sift4: https://siderite.blogspot.com/2014/11/super-fast-and-accurate-string-distance.html
if (maxOffset === undefined) {
maxOffset = 5; //default
}
if (!s1||!s1.length) {
if (!s2) {
return 0;
}
return s2.length;
}
if (!s2||!s2.length) {
return s1.length;
}
var l1=s1.length;
var l2=s2.length;
var c1 = 0; //cursor for string 1
var c2 = 0; //cursor for string 2
var lcss = 0; //largest common subsequence
var local_cs = 0; //local common substring
var trans = 0; //number of transpositions ('ab' vs 'ba')
var offset_arr=[]; //offset pair array, for computing the transpositions
while ((c1 < l1) && (c2 < l2)) {
if (s1.charAt(c1) == s2.charAt(c2)) {
local_cs++;
var isTrans=false;
//see if current match is a transposition
var i=0;
while (i=Math.abs(ofs.c2-ofs.c1);
if (isTrans)
{
trans++;
} else
{
if (!ofs.trans) {
ofs.trans=true;
trans++;
}
}
break;
} else {
if (c1>ofs.c2 && c2>ofs.c1) {
offset_arr.splice(i,1);
} else {
i++;
}
}
}
offset_arr.push({
c1:c1,
c2:c2,
trans:isTrans
});
} else {
lcss+=local_cs;
local_cs=0;
if (c1!=c2) {
c1=c2=Math.min(c1,c2); //using min allows the computation of transpositions
}
//if matching characters are found, remove 1 from both cursors (they get incremented at the end of the loop)
//so that we can have only one code block handling matches
for (var j = 0; j < maxOffset && (c1+j= l1) || (c2 >= l2)) {
lcss+=local_cs;
local_cs=0;
c1=c2=Math.min(c1,c2);
}
}
lcss+=local_cs;
return Math.round(Math.max(l1,l2)- lcss +trans); //add the cost of transpositions to the final result
},
splitEmail: function(email) {
email = email !== null ? (email.replace(/^\s*/, '').replace(/\s*$/, '')) : null; // trim() not exist in old IE!
var parts = email.split('@');
if (parts.length < 2) {
return false;
}
for (var i = 0; i < parts.length; i++) {
if (parts[i] === '') {
return false;
}
}
var domain = parts.pop();
var domainParts = domain.split('.');
var sld = '';
var tld = '';
if (domainParts.length === 0) {
// The address does not have a top-level domain
return false;
} else if (domainParts.length == 1) {
// The address has only a top-level domain (valid under RFC)
tld = domainParts[0];
} else {
// The address has a domain and a top-level domain
sld = domainParts[0];
for (var j = 1; j < domainParts.length; j++) {
tld += domainParts[j] + '.';
}
tld = tld.substring(0, tld.length - 1);
}
return {
topLevelDomain: tld,
secondLevelDomain: sld,
domain: domain,
address: parts.join('@')
};
},
// Encode the email address to prevent XSS but leave in valid
// characters, following this official spec:
// http://en.wikipedia.org/wiki/Email_address#Syntax
encodeEmail: function(email) {
var result = encodeURI(email);
result = result.replace('%20', ' ').replace('%25', '%').replace('%5E', '^')
.replace('%60', '`').replace('%7B', '{').replace('%7C', '|')
.replace('%7D', '}');
return result;
}
};
// Export the mailcheck object if we're in a CommonJS env (e.g. Node).
// Modeled off of Underscore.js.
if (typeof module !== 'undefined' && module.exports) {
module.exports = Mailcheck;
}
// Support AMD style definitions
// Based on jQuery (see http://stackoverflow.com/a/17954882/1322410)
if (typeof define === "function" && define.amd) {
define("mailcheck", [], function() {
return Mailcheck;
});
}
if (typeof window !== 'undefined' && window.jQuery) {
(function($){
$.fn.mailcheck = function(opts) {
var self = this;
if (opts.suggested) {
var oldSuggested = opts.suggested;
opts.suggested = function(result) {
oldSuggested(self, result);
};
}
if (opts.empty) {
var oldEmpty = opts.empty;
opts.empty = function() {
oldEmpty.call(null, self);
};
}
opts.email = this.val();
Mailcheck.run(opts);
};
})(jQuery);
}
;
!function(e){"use strict";function t(e,i,o){var a,n=document.createElement("img");return n.onerror=function(a){return t.onerror(n,a,e,i,o)},n.onload=function(a){return t.onload(n,a,e,i,o)},"string"==typeof e?(t.fetchBlob(e,function(i){i?(e=i,a=t.createObjectURL(e)):(a=e,o&&o.crossOrigin&&(n.crossOrigin=o.crossOrigin)),n.src=a},o),n):t.isInstanceOf("Blob",e)||t.isInstanceOf("File",e)?(a=n._objectURL=t.createObjectURL(e),a?(n.src=a,n):t.readFile(e,function(e){var t=e.target;t&&t.result?n.src=t.result:i&&i(e)})):void 0}function i(e,i){!e._objectURL||i&&i.noRevoke||(t.revokeObjectURL(e._objectURL),delete e._objectURL)}var o=window.createObjectURL&&window||window.URL&&URL.revokeObjectURL&&URL||window.webkitURL&&webkitURL;t.fetchBlob=function(e,t,i){t()},t.isInstanceOf=function(e,t){return Object.prototype.toString.call(t)==="[object "+e+"]"},t.transform=function(e,t,i,o,a){i(e,a)},t.onerror=function(e,t,o,a,n){i(e,n),a&&a.call(e,t)},t.onload=function(e,o,a,n,r){i(e,r),n&&t.transform(e,r,n,a,{})},t.createObjectURL=function(e){return!!o&&o.createObjectURL(e)},t.revokeObjectURL=function(e){return!!o&&o.revokeObjectURL(e)},t.readFile=function(e,t,i){if(window.FileReader){var o=new FileReader;if(o.onload=o.onerror=t,i=i||"readAsDataURL",o[i])return o[i](e),o}return!1},"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:e.loadImage=t}(window),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):e("object"==typeof module&&module.exports?require("./load-image"):window.loadImage)}(function(e){"use strict";var t=e.transform;e.transform=function(i,o,a,n,r){t.call(e,e.scale(i,o,r),o,a,n,r)},e.transformCoordinates=function(){},e.getTransformedOptions=function(e,t){var i,o,a,n,r=t.aspectRatio;if(!r)return t;i={};for(o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);return i.crop=!0,a=e.naturalWidth||e.width,n=e.naturalHeight||e.height,a/n>r?(i.maxWidth=n*r,i.maxHeight=n):(i.maxWidth=a,i.maxHeight=a/r),i},e.renderImageToCanvas=function(e,t,i,o,a,n,r,s,l,d){return e.getContext("2d").drawImage(t,i,o,a,n,r,s,l,d),e},e.hasCanvasOption=function(e){return e.canvas||e.crop||!!e.aspectRatio},e.scale=function(t,i,o){function a(){var e=Math.max((l||v)/v,(d||w)/w);e>1&&(v*=e,w*=e)}function n(){var e=Math.min((r||v)/v,(s||w)/w);e<1&&(v*=e,w*=e)}i=i||{};var r,s,l,d,c,u,f,g,h,m,p,S=document.createElement("canvas"),b=t.getContext||e.hasCanvasOption(i)&&S.getContext,x=t.naturalWidth||t.width,y=t.naturalHeight||t.height,v=x,w=y;if(b&&(i=e.getTransformedOptions(t,i,o),f=i.left||0,g=i.top||0,i.sourceWidth?(c=i.sourceWidth,void 0!==i.right&&void 0===i.left&&(f=x-c-i.right)):c=x-f-(i.right||0),i.sourceHeight?(u=i.sourceHeight,void 0!==i.bottom&&void 0===i.top&&(g=y-u-i.bottom)):u=y-g-(i.bottom||0),v=c,w=u),r=i.maxWidth,s=i.maxHeight,l=i.minWidth,d=i.minHeight,b&&r&&s&&i.crop?(v=r,w=s,p=c/u-r/s,p<0?(u=s*c/r,void 0===i.top&&void 0===i.bottom&&(g=(y-u)/2)):p>0&&(c=r*u/s,void 0===i.left&&void 0===i.right&&(f=(x-c)/2))):((i.contain||i.cover)&&(l=r=r||l,d=s=s||d),i.cover?(n(),a()):(a(),n())),b){if(h=i.pixelRatio,h>1&&(S.style.width=v+"px",S.style.height=w+"px",v*=h,w*=h,S.getContext("2d").scale(h,h)),m=i.downsamplingRatio,m>0&&m<1&&vv;)S.width=c*m,S.height=u*m,e.renderImageToCanvas(S,t,f,g,c,u,0,0,S.width,S.height),f=0,g=0,c=S.width,u=S.height,t=document.createElement("canvas"),t.width=c,t.height=u,e.renderImageToCanvas(t,S,0,0,c,u,0,0,c,u);return S.width=v,S.height=w,e.transformCoordinates(S,i),e.renderImageToCanvas(S,t,f,g,c,u,0,0,v,w)}return t.width=v,t.height=w,t}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):e("object"==typeof module&&module.exports?require("./load-image"):window.loadImage)}(function(e){"use strict";var t=window.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice);e.blobSlice=t&&function(){var e=this.slice||this.webkitSlice||this.mozSlice;return e.apply(this,arguments)},e.metaDataParsers={jpeg:{65505:[]}},e.parseMetaData=function(t,i,o,a){o=o||{},a=a||{};var n=this,r=o.maxMetaDataSize||262144,s=!(window.DataView&&t&&t.size>=12&&"image/jpeg"===t.type&&e.blobSlice);!s&&e.readFile(e.blobSlice.call(t,0,r),function(t){if(t.target.error)return console.log(t.target.error),void i(a);var r,s,l,d,c=t.target.result,u=new DataView(c),f=2,g=u.byteLength-4,h=f;if(65496===u.getUint16(0)){for(;f=65504&&r<=65519||65534===r);){if(s=u.getUint16(f+2)+2,f+s>u.byteLength){console.log("Invalid meta data: Invalid segment size.");break}if(l=e.metaDataParsers.jpeg[r])for(d=0;d6&&(c.slice?a.imageHead=c.slice(0,h):a.imageHead=new Uint8Array(c).subarray(0,h))}else console.log("Invalid JPEG file: Missing JPEG marker.");i(a)},"readAsArrayBuffer")||i(a)},e.hasMetaOption=function(e){return e&&e.meta};var i=e.transform;e.transform=function(t,o,a,n,r){e.hasMetaOption(o)?e.parseMetaData(n,function(r){i.call(e,t,o,a,n,r)},o,r):i.apply(e,arguments)}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(e){"use strict";"fetch"in window&&"Request"in window&&(e.fetchBlob=function(t,i,o){return e.hasMetaOption(o)?fetch(new Request(t,o)).then(function(e){return e.blob()}).then(i).catch(function(e){console.log(e),i()}):void i()})}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(e){"use strict";e.ExifMap=function(){return this},e.ExifMap.prototype.map={Orientation:274},e.ExifMap.prototype.get=function(e){return this[e]||this[this.map[e]]},e.getExifThumbnail=function(e,t,i){var o,a,n;if(!i||t+i>e.byteLength)return void console.log("Invalid Exif data: Invalid thumbnail data.");for(o=[],a=0;a4?i+t.getUint32(o+8,r):o+8,l+s>t.byteLength)return void console.log("Invalid Exif data: Invalid data offset.");if(1===n)return g.getValue(t,l,r);for(d=[],c=0;ce.byteLength)return void console.log("Invalid Exif data: Invalid directory offset.");if(n=e.getUint16(i,o),r=i+2+12*n,r+4>e.byteLength)return void console.log("Invalid Exif data: Invalid directory size.");for(s=0;st.byteLength)return void console.log("Invalid Exif data: Invalid segment size.");if(0!==t.getUint16(i+8))return void console.log("Invalid Exif data: Missing byte alignment offset.");switch(t.getUint16(d)){case 18761:r=!0;break;case 19789:r=!1;break;default:return void console.log("Invalid Exif data: Invalid byte alignment marker.")}if(42!==t.getUint16(d+2,r))return void console.log("Invalid Exif data: Missing TIFF marker.");s=t.getUint32(d+4,r),a.exif=new e.ExifMap,s=e.parseExifTags(t,d,d+s,r,a),s&&!n.disableExifThumbnail&&(l={exif:{}},s=e.parseExifTags(t,d,d+s,r,l),l.exif[513]&&(a.exif.Thumbnail=e.getExifThumbnail(t,d+l.exif[513],l.exif[514]))),a.exif[34665]&&!n.disableExifSub&&e.parseExifTags(t,d,d+a.exif[34665],r,a),a.exif[34853]&&!n.disableExifGps&&e.parseExifTags(t,d,d+a.exif[34853],r,a)}}},e.metaDataParsers.jpeg[65505].push(e.parseExifData)}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-exif"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-exif")):e(window.loadImage)}(function(e){"use strict";e.ExifMap.prototype.tags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright",36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",42240:"Gamma",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"PhotographicSensitivity",34856:"OECF",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"CameraOwnerName",42033:"BodySerialNumber",42034:"LensSpecification",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"},e.ExifMap.prototype.stringValues={ExposureProgram:{0:"Undefined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Undefined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},ComponentsConfiguration:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"},Orientation:{1:"top-left",2:"top-right",3:"bottom-right",4:"bottom-left",5:"left-top",6:"right-top",7:"right-bottom",8:"left-bottom"}},e.ExifMap.prototype.getText=function(e){var t=this.get(e);switch(e){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":case"Orientation":return this.stringValues[e][t];case"ExifVersion":case"FlashpixVersion":if(!t)return;return String.fromCharCode(t[0],t[1],t[2],t[3]);case"ComponentsConfiguration":if(!t)return;return this.stringValues[e][t[0]]+this.stringValues[e][t[1]]+this.stringValues[e][t[2]]+this.stringValues[e][t[3]];case"GPSVersionID":if(!t)return;return t[0]+"."+t[1]+"."+t[2]+"."+t[3]}return String(t)},function(e){var t,i=e.tags,o=e.map;for(t in i)i.hasOwnProperty(t)&&(o[i[t]]=t)}(e.ExifMap.prototype),e.ExifMap.prototype.getAll=function(){var e,t,i={};for(e in this)this.hasOwnProperty(e)&&(t=this.tags[e],t&&(i[t]=this.getText(t)));return i}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-scale","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-scale"),require("./load-image-meta")):e(window.loadImage)}(function(e){"use strict";var t=e.hasCanvasOption,i=e.hasMetaOption,o=e.transformCoordinates,a=e.getTransformedOptions;e.hasCanvasOption=function(i){return!!i.orientation||t.call(e,i)},e.hasMetaOption=function(t){return t&&t.orientation===!0||i.call(e,t)},e.transformCoordinates=function(t,i){o.call(e,t,i);var a=t.getContext("2d"),n=t.width,r=t.height,s=t.style.width,l=t.style.height,d=i.orientation;if(d&&!(d>8))switch(d>4&&(t.width=r,t.height=n,t.style.width=l,t.style.height=s),d){case 2:a.translate(n,0),a.scale(-1,1);break;case 3:a.translate(n,r),a.rotate(Math.PI);break;case 4:a.translate(0,r),a.scale(1,-1);break;case 5:a.rotate(.5*Math.PI),a.scale(1,-1);break;case 6:a.rotate(.5*Math.PI),a.translate(0,-r);break;case 7:a.rotate(.5*Math.PI),a.translate(n,-r),a.scale(-1,1);break;case 8:a.rotate(-.5*Math.PI),a.translate(-n,0)}},e.getTransformedOptions=function(t,i,o){var n,r,s=a.call(e,t,i),l=s.orientation;if(l===!0&&o&&o.exif&&(l=o.exif.get("Orientation")),!l||l>8||1===l)return s;n={};for(r in s)s.hasOwnProperty(r)&&(n[r]=s[r]);switch(n.orientation=l,l){case 2:n.left=s.right,n.right=s.left;break;case 3:n.left=s.right,n.top=s.bottom,n.right=s.left,n.bottom=s.top;break;case 4:n.top=s.bottom,n.bottom=s.top;break;case 5:n.left=s.top,n.top=s.left,n.right=s.bottom,n.bottom=s.right;break;case 6:n.left=s.top,n.top=s.right,n.right=s.bottom,n.bottom=s.left;break;case 7:n.left=s.bottom,n.top=s.right,n.right=s.top,n.bottom=s.left;break;case 8:n.left=s.bottom,n.top=s.left,n.right=s.top,n.bottom=s.right}return n.orientation>4&&(n.maxWidth=s.maxHeight,n.maxHeight=s.maxWidth,n.minWidth=s.minHeight,n.minHeight=s.minWidth,n.sourceWidth=s.sourceHeight,n.sourceHeight=s.sourceWidth),n}});
;
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("..\\index.html"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("..\\index.html"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("..\\index.html")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("..\\index.html"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("..\\index.html"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("..\\index.html")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("..\\index.html"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;hc;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a(''),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html(''),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html(''),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('×');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e0||0===c.length)){var d=a('×');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"?":"A","A":"A","À":"A","Á":"A","Â":"A","?":"A","?":"A","?":"A","?":"A","Ã":"A","A":"A","A":"A","?":"A","?":"A","?":"A","?":"A","?":"A","?":"A","Ä":"A","A":"A","?":"A","Å":"A","?":"A","A":"A","?":"A","?":"A","?":"A","?":"A","?":"A","?":"A","A":"A","?":"A","?":"A","?":"AA","Æ":"AE","?":"AE","?":"AE","?":"AO","?":"AU","?":"AV","?":"AV","?":"AY","?":"B","B":"B","?":"B","?":"B","?":"B","?":"B","?":"B","?":"B","?":"C","C":"C","C":"C","C":"C","C":"C","C":"C","Ç":"C","?":"C","?":"C","?":"C","?":"C","?":"D","D":"D","?":"D","D":"D","?":"D","?":"D","?":"D","?":"D","Ð":"D","?":"D","?":"D","Ð":"D","?":"D","?":"DZ","?":"DZ","?":"Dz","?":"Dz","?":"E","E":"E","È":"E","É":"E","Ê":"E","?":"E","?":"E","?":"E","?":"E","?":"E","E":"E","?":"E","?":"E","E":"E","E":"E","Ë":"E","?":"E","E":"E","?":"E","?":"E","?":"E","?":"E","?":"E","?":"E","E":"E","?":"E","?":"E","?":"E","?":"E","?":"F","F":"F","?":"F","ƒ":"F","?":"F","?":"G","G":"G","?":"G","G":"G","?":"G","G":"G","G":"G","G":"G","G":"G","G":"G","?":"G","?":"G","?":"G","?":"G","?":"H","H":"H","H":"H","?":"H","?":"H","?":"H","?":"H","?":"H","?":"H","H":"H","?":"H","?":"H","?":"H","?":"I","I":"I","Ì":"I","Í":"I","Î":"I","I":"I","I":"I","I":"I","I":"I","Ï":"I","?":"I","?":"I","I":"I","?":"I","?":"I","?":"I","I":"I","?":"I","I":"I","?":"J","J":"J","J":"J","?":"J","?":"K","K":"K","?":"K","K":"K","?":"K","K":"K","?":"K","?":"K","?":"K","?":"K","?":"K","?":"K","?":"K","?":"L","L":"L","?":"L","L":"L","L":"L","?":"L","?":"L","L":"L","?":"L","?":"L","L":"L","?":"L","?":"L","?":"L","?":"L","?":"L","?":"L","?":"LJ","?":"Lj","?":"M","M":"M","?":"M","?":"M","?":"M","?":"M","?":"M","?":"N","N":"N","?":"N","N":"N","Ñ":"N","?":"N","N":"N","?":"N","N":"N","?":"N","?":"N","?":"N","?":"N","?":"N","?":"N","?":"NJ","?":"Nj","?":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","?":"O","?":"O","?":"O","?":"O","Õ":"O","?":"O","?":"O","?":"O","O":"O","?":"O","?":"O","O":"O","?":"O","?":"O","Ö":"O","?":"O","?":"O","O":"O","O":"O","?":"O","?":"O","O":"O","?":"O","?":"O","?":"O","?":"O","?":"O","?":"O","?":"O","O":"O","O":"O","Ø":"O","?":"O","?":"O","O":"O","?":"O","?":"O","?":"OI","?":"OO","?":"OU","?":"P","P":"P","?":"P","?":"P","?":"P","?":"P","?":"P","?":"P","?":"P","?":"Q","Q":"Q","?":"Q","?":"Q","?":"Q","?":"R","R":"R","R":"R","?":"R","R":"R","?":"R","?":"R","?":"R","?":"R","R":"R","?":"R","?":"R","?":"R","?":"R","?":"R","?":"R","?":"S","S":"S","?":"S","S":"S","?":"S","S":"S","?":"S","Š":"S","?":"S","?":"S","?":"S","?":"S","S":"S","?":"S","?":"S","?":"S","?":"T","T":"T","?":"T","T":"T","?":"T","?":"T","T":"T","?":"T","?":"T","T":"T","?":"T","T":"T","?":"T","?":"T","?":"TZ","?":"U","U":"U","Ù":"U","Ú":"U","Û":"U","U":"U","?":"U","U":"U","?":"U","U":"U","Ü":"U","U":"U","U":"U","U":"U","U":"U","?":"U","U":"U","U":"U","U":"U","?":"U","?":"U","U":"U","?":"U","?":"U","?":"U","?":"U","?":"U","?":"U","?":"U","U":"U","?":"U","?":"U","?":"U","?":"V","V":"V","?":"V","?":"V","?":"V","?":"V","?":"V","?":"VY","?":"W","W":"W","?":"W","?":"W","W":"W","?":"W","?":"W","?":"W","?":"W","?":"X","X":"X","?":"X","?":"X","?":"Y","Y":"Y","?":"Y","Ý":"Y","Y":"Y","?":"Y","?":"Y","?":"Y","Ÿ":"Y","?":"Y","?":"Y","?":"Y","?":"Y","?":"Y","?":"Z","Z":"Z","Z":"Z","?":"Z","Z":"Z","Ž":"Z","?":"Z","?":"Z","?":"Z","?":"Z","?":"Z","?":"Z","?":"Z","?":"a","a":"a","?":"a","à":"a","á":"a","â":"a","?":"a","?":"a","?":"a","?":"a","ã":"a","a":"a","a":"a","?":"a","?":"a","?":"a","?":"a","?":"a","?":"a","ä":"a","a":"a","?":"a","å":"a","?":"a","a":"a","?":"a","?":"a","?":"a","?":"a","?":"a","?":"a","a":"a","?":"a","?":"a","?":"aa","æ":"ae","?":"ae","?":"ae","?":"ao","?":"au","?":"av","?":"av","?":"ay","?":"b","b":"b","?":"b","?":"b","?":"b","b":"b","?":"b","?":"b","?":"c","c":"c","c":"c","c":"c","c":"c","c":"c","ç":"c","?":"c","?":"c","?":"c","?":"c","?":"c","?":"d","d":"d","?":"d","d":"d","?":"d","?":"d","?":"d","?":"d","d":"d","?":"d","?":"d","?":"d","?":"d","?":"dz","?":"dz","?":"e","e":"e","è":"e","é":"e","ê":"e","?":"e","?":"e","?":"e","?":"e","?":"e","e":"e","?":"e","?":"e","e":"e","e":"e","ë":"e","?":"e","e":"e","?":"e","?":"e","?":"e","?":"e","?":"e","?":"e","e":"e","?":"e","?":"e","?":"e","?":"e","?":"e","?":"f","f":"f","?":"f","ƒ":"f","?":"f","?":"g","g":"g","?":"g","g":"g","?":"g","g":"g","g":"g","g":"g","g":"g","g":"g","?":"g","?":"g","?":"g","?":"g","?":"h","h":"h","h":"h","?":"h","?":"h","?":"h","?":"h","?":"h","?":"h","?":"h","h":"h","?":"h","?":"h","?":"h","?":"hv","?":"i","i":"i","ì":"i","í":"i","î":"i","i":"i","i":"i","i":"i","ï":"i","?":"i","?":"i","i":"i","?":"i","?":"i","?":"i","i":"i","?":"i","?":"i","i":"i","?":"j","j":"j","j":"j","j":"j","?":"j","?":"k","k":"k","?":"k","k":"k","?":"k","k":"k","?":"k","?":"k","?":"k","?":"k","?":"k","?":"k","?":"k","?":"l","l":"l","?":"l","l":"l","l":"l","?":"l","?":"l","l":"l","?":"l","?":"l","?":"l","l":"l","l":"l","?":"l","?":"l","?":"l","?":"l","?":"l","?":"lj","?":"m","m":"m","?":"m","?":"m","?":"m","?":"m","?":"m","?":"n","n":"n","?":"n","n":"n","ñ":"n","?":"n","n":"n","?":"n","n":"n","?":"n","?":"n","?":"n","?":"n","?":"n","?":"n","?":"n","?":"nj","?":"o","o":"o","ò":"o","ó":"o","ô":"o","?":"o","?":"o","?":"o","?":"o","õ":"o","?":"o","?":"o","?":"o","o":"o","?":"o","?":"o","o":"o","?":"o","?":"o","ö":"o","?":"o","?":"o","o":"o","o":"o","?":"o","?":"o","o":"o","?":"o","?":"o","?":"o","?":"o","?":"o","?":"o","?":"o","o":"o","o":"o","ø":"o","?":"o","?":"o","?":"o","?":"o","?":"o","?":"oi","?":"ou","?":"oo","?":"p","p":"p","?":"p","?":"p","?":"p","?":"p","?":"p","?":"p","?":"p","?":"q","q":"q","?":"q","?":"q","?":"q","?":"r","r":"r","r":"r","?":"r","r":"r","?":"r","?":"r","?":"r","?":"r","r":"r","?":"r","?":"r","?":"r","?":"r","?":"r","?":"r","?":"s","s":"s","ß":"s","s":"s","?":"s","s":"s","?":"s","š":"s","?":"s","?":"s","?":"s","?":"s","s":"s","?":"s","?":"s","?":"s","?":"s","?":"t","t":"t","?":"t","?":"t","t":"t","?":"t","?":"t","t":"t","?":"t","?":"t","t":"t","?":"t","?":"t","?":"t","?":"t","?":"tz","?":"u","u":"u","ù":"u","ú":"u","û":"u","u":"u","?":"u","u":"u","?":"u","u":"u","ü":"u","u":"u","u":"u","u":"u","u":"u","?":"u","u":"u","u":"u","u":"u","?":"u","?":"u","u":"u","?":"u","?":"u","?":"u","?":"u","?":"u","?":"u","?":"u","u":"u","?":"u","?":"u","?":"u","?":"v","v":"v","?":"v","?":"v","?":"v","?":"v","?":"v","?":"vy","?":"w","w":"w","?":"w","?":"w","w":"w","?":"w","?":"w","?":"w","?":"w","?":"w","?":"x","x":"x","?":"x","?":"x","?":"y","y":"y","?":"y","ý":"y","y":"y","?":"y","?":"y","?":"y","ÿ":"y","?":"y","?":"y","?":"y","?":"y","?":"y","?":"y","?":"z","z":"z","z":"z","?":"z","z":"z","ž":"z","?":"z","?":"z","z":"z","?":"z","?":"z","?":"z","?":"z","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"O","?":"a","?":"e","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"?","?":"s"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){
var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a(''),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a(""),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.topf.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),
this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("select2/compat/utils",["jquery"],function(a){function b(b,c,d){var e,f,g=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0===this.indexOf("select2-")&&g.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&(f=d(this),null!=f&&g.push(f))})),b.attr("class",g.join(" "))}return{syncCssClasses:b}}),b.define("select2/compat/containerCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("containerCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptContainerCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("containerCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/dropdownCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("dropdownCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptDropdownCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("dropdownCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/initSelection",["jquery"],function(a){function b(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=c.get("initSelection"),this._isInitialized=!1,a.call(this,b,c)}return b.prototype.current=function(b,c){var d=this;return this._isInitialized?void b.call(this,c):void this.initSelection.call(null,this.$element,function(b){d._isInitialized=!0,a.isArray(b)||(b=[b]),c(b)})},b}),b.define("select2/compat/inputData",["jquery"],function(a){function b(a,b,c){this._currentData=[],this._valueSeparator=c.get("valueSeparator")||",","hidden"===b.prop("type")&&c.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `